Text box in VBA Excel

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024
  • Text box in VBA Excel. How to make and populate text boxes with VBA.
    Free templates and templates with code are available for purchase for $50 USD
    www.easyexcela...
    Addition Templates may be available on request
    Click this link to check out my one-on-one training www.calendly.co...
    For more help visit my website www.easyexcelanswers.com or email me at easyexcelanswers@gmail.com.
    Contact me regarding customizing this template for your needs.
    Click for online Excel Consulting www.calendly.co...
    Are you struggling to update your Microsoft SQL Server data?
    I recommend using well-known Excel to update and manage your data in SQL Server using the SQL Spreads Excel add-in.
    Click sqlspreads.com... to find out how SQL Spreads works best for non-technical end users and download our free 14-day trial. You will get two months free when purchasing an annual subscription using our link.
    I am able to provide online help on your computer at a reasonable rate.
    Check out Crowdcast for creating your webinars
    app.linkmink.c...
    I use Tube Buddy to help promote my videos
    Check them out
    www.Tubebuddy....
    Follow me on Facebook
    / easyexcel.answers
    IG @barbhendersonconsulting
    You can help and generate a translation to you own language
    www.youtube.com...
    *this description may contain affiliate links. When you click them, I may receive a small commission at no extra cost to you. I only recommend products and services that I've used or have experience with.
    How to insert VBA code in Excel • How to insert VBA code...
    Sub textbox()
    'create a textbox
    Dim str As String
    Dim ws As Worksheet
    Set ws = Sheet3
    ws.Cells(7, 3).Select
    ws.shapes.AddTextbox(msoTextOrientationHorizontal, _
    100, 100, 200, 200) _
    .TextFrame.Characters.Text = ""
    'mydocuments.shapes.Select
    For Each oneShape In ws.shapes
    oneShape.Select Replace:=False
    'Next oneShape
    Selection.copy
    r = 7
    C = 2
    ws.Cells(r, 8).Select
    ActiveSheet.Paste
    ws.Cells(r, 13).Select
    ActiveSheet.Paste
    ws.Cells(r, 18).Select
    ActiveSheet.Paste
    Next
    Call addtext
    End Sub
    Sub addtext()
    Dim oTextBox As textbox
    Dim data, ws As Worksheet
    Dim com, addr As String
    Dim city, prov As String
    Dim pc As String
    Dim r As Long
    Set ws = Sheet3
    Set data = Sheet2
    r = 2
    ws.Activate
    For Each oTextBox In ws.TextBoxes
    com = data.Cells(r, 1).Value
    addr = data.Cells(r, 2).Value
    city = data.Cells(r, 3).Value
    prov = data.Cells(r, 4).Value
    pc = data.Cells(r, 5).Value

    oTextBox.Select
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = _
    com & vbLf & addr & vbLf & city & vbLf & prov & vbLf & pc
    r = r + 1
    Next oTextBox

    End Sub
    Sub delettxt()
    Dim oTextBox As textbox
    Sheet3.Activate
    For Each oTextBox In ActiveSheet.TextBoxes
    oTextBox.Delete
    Next oTextBox
    End Sub

Комментарии • 2