vba newbie HELP!!!!!

Joined
Oct 31, 2012
Messages
5
Reaction score
0
Points
1
i have a VBA code written for PC that does not work on MAC, i need a MAC guru to assist??

anyone outthere can help me??

thanks

kl
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,771
Reaction score
2,111
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Visual Basic is meant for Windows, it will not work on a Mac. If you have a VB program that has been compiled into an executable, depending on what it is, you could perhaps try it through Wine or something..otherwise you'll need a Windows installation on your Mac..
 
OP
K
Joined
Oct 31, 2012
Messages
5
Reaction score
0
Points
1
Visual Basic is meant for Windows, it will not work on a Mac. If you have a VB program that has been compiled into an executable, depending on what it is, you could perhaps try it through Wine or something..otherwise you'll need a Windows installation on your Mac..

this was what i had, its only the open file commands and saving commands that are not working, the rest is on mac!! any ideas?

Code:
Option Explicit

Sub sageOCT()
Dim lrow As Long, i As Long
Dim fname As Variant
Dim fpath As String, fname1 as string

Application.ScreenUpdating = False
Application.DisplayAlerts = False

fname = Application.GetOpenFilename(FileFilter:="All files (*.*), *.*", Title:="Please open the csv file")
If fname = "False" Then
    MsgBox "You have not selected a file."
    Exit Sub
Else
    Workbooks.Open Filename:=fname
    fname = ActiveWorkbook.Name
End If

With Workbooks(fname).Worksheets(1)
    .Rows("1:1").Delete
    .Columns("F:F").Delete
    .Columns(1).Insert
    lrow = .Range("B" & .Rows.Count).End(xlUp).Row
    .Rows(1).Insert
    For i = lrow To 2 Step -1
        If .Range("B" & i).Value = "" Then .Rows(i).Delete
    Next i
    .Rows(1).Delete
    lrow = .Range("B" & .Rows.Count).End(xlUp).Row
    .Range("A1:A" & lrow).FormulaR1C1 = "=CONCATENATE(RC[2], ""  "",RC[3], ""  "",RC[1])"
    .Columns("A:A").ColumnWidth = 32.17
    .Columns("A:A").Copy
    .Columns("D:D").PasteSpecial (xlPasteValues)
    Application.CutCopyMode = False
    .Columns("A:A").Delete
    .Columns("B:B").Delete
    .Columns("B:B").ColumnWidth = 63.83
    .Range("G1:G" & lrow).FormulaR1C1 = "=IF(LEFT(RC[-5],1)=""N"",MID(RC[-5],6,250),RC[-5])"
    .Columns("G:G").ColumnWidth = 37.5
    .Columns("G:G").Copy
    .Columns("B:B").PasteSpecial (xlPasteValues)
    Application.CutCopyMode = False
    .Columns("G:G").Delete
    .Range("E1:E" & lrow).FormulaR1C1 = "=IF(RC[-2]="""", "" "", ""1"")"
    .Columns("E:E").Copy
    .Columns("E:E").PasteSpecial (xlPasteValues)
    .Range("N1:N" & lrow).FormulaR1C1 = "=IF(RC[-11]="""", "" "", ""2"")"
    .Columns("N:N").Copy
    .Columns("N:N").PasteSpecial (xlPasteValues)
End With

fpath = "D:\Test"
fname1 = Format(Date, "ddmmyyyy") & ".csv"
Workbooks(fname).SaveAs Filename:=fpath & "\" & fname1, FileFormat:=xlCSV

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,771
Reaction score
2,111
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
You might have better luck if you convert this VBA script to AppleScript to make it work on the Mac. And what dose "rest is on Mac" mean? There is no support to execute a VB script on OS X, so no real way around that..
 
OP
K
Joined
Oct 31, 2012
Messages
5
Reaction score
0
Points
1
i meant if i use just the middle part of the code and not the beginning or end it works on mac
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,771
Reaction score
2,111
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
How are you using the middle part? Within Excel or something?
 
OP
K
Joined
Oct 31, 2012
Messages
5
Reaction score
0
Points
1
within excel yes, maybe what im trying to achieve will be better done as applescript??? can i send you some attachments and explain what i am trying to do?
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,771
Reaction score
2,111
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Gotcha, if you google "converting VBA to AppleScript" you will get a bunch of results including a MacTech 150 page article on how to do it. Depending on your version of Office, it should have good support for AppleScript and you should be able to do everything you are doing in the VBA script..
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top