Hello all! Many thanks for your help to date on this forum. I'm a novice to VBA so apologies if this post is too simple.
On a particular worksheet ("sheet1"), I'm trying to re-calculate the workbook, insert a column in specific column (column AB) and then copy and paste certain columns (columns H:L) within the same worksheet to other columns within that worksheet, and finally clear contents (Columns B:G) in another worksheet ("Input Page"). I then try and assign this macro to a button on a different worksheet ("Input Page").
However, the problem is that when i run the macro on the other sheet, it only copy and pastes the columns in the active worksheet that I click the button. I think it's something to do with my cell referencing. See my code below which was produced using the Record Macro option in the Developer tab. Thanks a million for your help!
Sub Macro11()
'
' Macro11 Macro
Calculate
Columns("AB:AB").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("H:L").Select
Selection.copy
Columns("AB:AB").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Input page").Select
Columns("B:G").Select
Selection.ClearContents
End Sub
Sub Run_Macro() ' contained in worksheet 'Input Page'
Call Macro11
End Sub
On a particular worksheet ("sheet1"), I'm trying to re-calculate the workbook, insert a column in specific column (column AB) and then copy and paste certain columns (columns H:L) within the same worksheet to other columns within that worksheet, and finally clear contents (Columns B:G) in another worksheet ("Input Page"). I then try and assign this macro to a button on a different worksheet ("Input Page").
However, the problem is that when i run the macro on the other sheet, it only copy and pastes the columns in the active worksheet that I click the button. I think it's something to do with my cell referencing. See my code below which was produced using the Record Macro option in the Developer tab. Thanks a million for your help!
Sub Macro11()
'
' Macro11 Macro
Calculate
Columns("AB:AB").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("H:L").Select
Selection.copy
Columns("AB:AB").Select
Selection.Insert Shift:=xlToRight
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Input page").Select
Columns("B:G").Select
Selection.ClearContents
End Sub
Sub Run_Macro() ' contained in worksheet 'Input Page'
Call Macro11
End Sub