I've made a VBA for a button in Excel for Mac that is supposed to copy the content of a few selected cells on one tab and paste it (as values) on the first available cell in an assigned row on a different tab.
This is the first time I've ever had a go at making this, so I probably didn't do it as efficient as possible, but it works.
The problem is that it only works on Mac. My co-workers that I've made it for uses PC. Can I convert the code to work on Excel for PC?
Edit: I should have been more explicit into what the problem actually is (thanks @KenWhite).
So here's what happened:
- I created the file and the VBA.
- I saved my file and attatched it to an email
- my co-worker saved it and opened it up
- When she pressed the button she got an error "Indexet är utanför intervall". My best translation for this is Index out of Range (but I'm not completely sure)
I suspected that it had to do with Mac -> PC, but some have pointed out that there should be no difference. I realize that the named on the sheets and that the data needs to be in the exact same spot - but that shouldn't be an issue in this case.
Edit 2: It seems to be a problem with special characters. the "ä" and "ö" used in the sheet names where changed in to "š" and "¨" in the VBA code on their end. I can't test it right now, but my guess is that the code will work if I either manually change the characters in the code or make sure to use sheet names without special characters.
If I should/could add additional information, let me know and I'll make another edit.
Thank you everyone.
Sub Generera()
'
' Generera Makro
'
'
Range("B1").Select
Selection.Copy
Sheets("Utveckling över tid").Select
BMaxRows = Cells(Rows.Count, "B").End(xlUp).Row
Range("B" & BMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B2").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
CMaxRows = Cells(Rows.Count, "C").End(xlUp).Row
Range("C" & CMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
DMaxRows = Cells(Rows.Count, "D").End(xlUp).Row
Range("D" & DMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
EMaxRows = Cells(Rows.Count, "E").End(xlUp).Row
Range("E" & EMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B6").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
FMaxRows = Cells(Rows.Count, "F").End(xlUp).Row
Range("F" & FMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B7").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
GMaxRows = Cells(Rows.Count, "G").End(xlUp).Row
Range("G" & GMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B8").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
HMaxRows = Cells(Rows.Count, "H").End(xlUp).Row
Range("H" & HMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B9").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("veckoräckvidd").Select
Range("B11").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
IMaxRows = Cells(Rows.Count, "I").End(xlUp).Row
Range("I" & IMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("veckoräckvidd").Select
Range("B12").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Utveckling över tid").Select
JMaxRows = Cells(Rows.Count, "J").End(xlUp).Row
Range("J" & JMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub