[VBA] Set particular input cells to specific rows (use of for loop)

HarrisonChong

New Member
Joined
Nov 16, 2016
Messages
10
Good day,

As below code, it copies whatever value in A1:C1 to empty row, start from E2:G2 (Credit goes to tygrrboi).
Can anyone help to modify the code, as I tried to modify myself and I have very limited knowledge in VBA, which I couldn't make it myself.

I have 5 input fields from different cell, which are C18, B3, C20, C22 and C24 (Input). I attempt to copy the value from these cells, then arrange in a proper manner as B41:B45 (As output).
Below is the explanation of where the input flow.
Whereas, C18 value goes to B41, B3 value goes to B42, C20 value in B43, C22 value in B44 and C24 value in B45.
However, when the button clicks for 2nd times, then the output will C41:C45 and on so (consider as infinite loop)

Appreciate of anyone who try to help, thank you.
Code:
Private Sub CopyAcross_Click()Dim R As Range
Dim rSize As Integer, numCopies As Integer, i As Integer
Dim nextEmptyRow As Long
With ActiveSheet
    Set R = .Range("A1:C1")
    rSize = R.Count
    LastRow = .Cells(.Rows.Count, rSize + 1).End(xlUp).Row
End With
numCopies = 3
For i = 1 To numCopies
    R.Copy R.Offset(LastRow, i * rSize)
Next i
End Sub
 
Hi Howard,

I sincerely appreciate of your kind help and sorry for late reply. I am kinda busy at this moment, I will try this code of yours as soon as I am free to do so.
Many thanks!
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,219
Messages
6,123,680
Members
449,116
Latest member
HypnoFant

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