Results 1 to 3 of 3

Thread: Request Assistance to convert VBA to VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2021

    Request Assistance to convert VBA to VB


    I am working with automation software that has an activity that runs macros. I understood it to be VBA, but I keep running into errors. When I looked at the sample, I noticed a difference in the language being used in the VBS file. Below is the sample file language.

    Sub TestMacros(color1, color2)
    Dim xlApp, EmailBook
    Set xlApp = CreateObject("Excel.Application")
    Set EmailBook = xlApp.Workbooks.Open(WScript.Arguments(0))
    EmailBook.Sheets("data").Range("B2:B3").Interior.ColorIndex = color1
    EmailBook.Sheets("data").Range("B4:B5").Interior.ColorIndex = color2
    EmailBook.Close True
    End Sub

    Below is the VBA I created. How can I get the VBA converted to the above format? Is this VB .Net or something else? Are there any resources you would recommend for learning this? Thank you in advance!

    Sub ReplaceHyphens()
    Columns("C").Replace What:="-", Replacement:="", _
    LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
    End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Request Assistance to convert VBA to VB

    That first snippet is not VB.NET. The Set keyword is not used in VB.NET. It must be VB6. I don't really know what you're asking for. Are you saying that you want VB.NET code equivalent to that VB6 code? If so then what is the relevance of the VBA?

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Columbus, Ohio

    Re: Request Assistance to convert VBA to VB

    Dim X as string
    X = "555-333"
    X = replace(X,"-","")
    Please remember next time...elections matter!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width