Hi,
Can someone please take a look at the code below? I keep getting an error when trying to run the code. The code was given to me by a co worker whom is no longer around. I need help because I'm too amateur with VBA and need some pro tip. Thanks!
About the code: It's suppose to copy specific fields from one worksheet to another worksheet.
Sub PasteLinks()
Dim ibox1 As Integer, ibox2 As Integer
Dim addy As String
Dim WSName1 As String, WSName2 As String
WSName1 = "ALLFUNDS_BS" 'copy from sheet
WSName2 = "NonMajor Special Revenue BS" 'paste to sheet
Worksheets(WSName1).Activate
ibox1 = InputBox("Please input row # to copy from")
ibox2 = InputBox("Please input row # to paste to")
Worksheets(WSName2).Activate
Range("G" & ibox2).Activate 'change this to first pasted column
Worksheets(WSName1).Activate
Range("L" & ibox1).Activate 'change this to first copied column
Do
addy = ActiveCell.Address(False, False)
Worksheets(WSName2).Activate
ActiveCell.Value = "=IF(" & WSName1 & "!" & addy & "="""",""""," & WSName1 & "!" & addy & ")"
ActiveCell.Offset(0, 2).Activate 'change this IF no blank column in between
Worksheets(WSName1).Activate
ActiveCell.Offset(0, 2).Activate 'change this IF no budget + 2 blank columns in between
Loop Until ActiveCell.Address(False, False) = "BL" & ibox1 'change BL to last column you want copied + offset number above
Worksheets(WSName2).Activate
End Sub
Can someone please take a look at the code below? I keep getting an error when trying to run the code. The code was given to me by a co worker whom is no longer around. I need help because I'm too amateur with VBA and need some pro tip. Thanks!
About the code: It's suppose to copy specific fields from one worksheet to another worksheet.
Sub PasteLinks()
Dim ibox1 As Integer, ibox2 As Integer
Dim addy As String
Dim WSName1 As String, WSName2 As String
WSName1 = "ALLFUNDS_BS" 'copy from sheet
WSName2 = "NonMajor Special Revenue BS" 'paste to sheet
Worksheets(WSName1).Activate
ibox1 = InputBox("Please input row # to copy from")
ibox2 = InputBox("Please input row # to paste to")
Worksheets(WSName2).Activate
Range("G" & ibox2).Activate 'change this to first pasted column
Worksheets(WSName1).Activate
Range("L" & ibox1).Activate 'change this to first copied column
Do
addy = ActiveCell.Address(False, False)
Worksheets(WSName2).Activate
ActiveCell.Value = "=IF(" & WSName1 & "!" & addy & "="""",""""," & WSName1 & "!" & addy & ")"
ActiveCell.Offset(0, 2).Activate 'change this IF no blank column in between
Worksheets(WSName1).Activate
ActiveCell.Offset(0, 2).Activate 'change this IF no budget + 2 blank columns in between
Loop Until ActiveCell.Address(False, False) = "BL" & ibox1 'change BL to last column you want copied + offset number above
Worksheets(WSName2).Activate
End Sub