Need help deciphering VBA code

ugkwan

New Member
Joined
Aug 26, 2016
Messages
4
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
 
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,215,425
Messages
6,124,826
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top