VBA loop until blank- copy & paste &copy & paste

josh456Excel

New Member
Joined
Nov 23, 2021
Messages
2
Platform
  1. Windows
VBA loop until blank- Sheet 1 B4 copy, paste it Sheet2 C3, copy the result sheet2 D3, paste it in C4 on Sheet1, next row in sheet 1 (example B5). Continue until blank in Sheet1 column B.

This is my first ever post so let me know if you need more info. Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi and welcome to MrExcel.

Try this:

VBA Code:
Sub vbaloop()
  Dim c As Range
  For Each c In Sheets("Sheet1").Range("B4", Sheets("Sheet1").Range("B" & Rows.Count).End(3))
    With Sheets("Sheet2")
      .Range("C3").Value = c.Value
      c.Offset(, 1).Value = .Range("D3").Value
    End With
  Next
End Sub
 
Upvote 0
Hi and welcome to MrExcel.

Try this:

VBA Code:
Sub vbaloop()
  Dim c As Range
  For Each c In Sheets("Sheet1").Range("B4", Sheets("Sheet1").Range("B" & Rows.Count).End(3))
    With Sheets("Sheet2")
      .Range("C3").Value = c.Value
      c.Offset(, 1).Value = .Range("D3").Value
    End With
  Next
End Sub
That works! I appreciate your help!! I spent several hours trying to figure that out using the record function with no luck. Thanks again
 
Upvote 0
Hello,

I have also a similar question and thought it would be much better to continue in this thread rather than creating a new one. I would appreciate if you could kindly help me with it.

The VBA code above is helped me for the initial stage but I could not go further. I am trying to copy multiple data from one worksheet to another. In my case,

1- Copy the value from D2 of Sheet1 to H26 of Sheet2
2- Copy the value from H2 of Sheet1
2-1- if A1 of Sheet2 is empty, to H27 of Sheet2
2-2- else to H28 of Sheet2
3- Copy the value from I2 of Sheet1
3-1- if A1 of Sheet2 is empty, to H28 of Sheet2
3-2- else to H27 of Sheet2
4- Copy the result from H35 of Sheet2 to J2 of Sheet1
5- Copy the result from H28 of Sheet3 to K2 of Sheet1

I have some calcs in sheet 2 and 3 which are linked to each other so input in sheet 2, which should be coming from sheet 1 also gives some results in sheet 3 and I am trying to take the outputs from sheet 2 and 3, and compile them in sheet 1.

Everything got complicated especially with if clause and multiple data copy. I can create the logic and flow in my mind but I could not manage to run it. Any help from your side would be very much appreciated.

Thanks a lot for your help in advance!
 
Upvote 0
I have also a similar question and thought it would be much better to continue in this thread rather than creating a new one.
Your question is not that similar to the op, so please start a new thread for this question.
Thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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