Replacing cell value with a range of cell values

bhope_691

New Member
Joined
Mar 10, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have data on Sheet1 in column A which is inputted dynamically via a userform. The data exists in column A like:

Column A
AB1234
BC1256
GF4567

I want to copy this data to sheet2 which has another set of data inputted dynamically via a second userform.

I want to copy the data, to specific cells in sheet2 which are determined by data inputted into the second userform, i.e it is dynamic and changes, so I can't reference them directly.

I have tried to fill the specific cells with dashes (-) and then replace the dashes(-) with the values in column A, but I cannot seem to cycle through the values in column A on sheet1.

This is the part of the code that I have tried using to replace the dashes with the values in column A sheet1. It runs with no errors but the dashes do not change to the values in column A.

Set r3 = Range("B2:B100") 'range where the data is sent to
For each cell3 in r3
If cell3.value = "-" Then
cell3.Value = Range("Sheet1!A2:A6") 'range where I am taking the data from
End If
Next

I know if I change the code in line 4 - Cell3.Value = Range(Sheet1!A2") all the dashes change to the value in A2. However, I need the first dash to be A2, second dash to be A3 and so on. I don't know how many values will be in column A.

Thanks.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Figured it out.

Dim i As Integer
For i = 1 To 10
Set r3 = Range("B2:B100") 'range where the data is sent to
For each cell3 in r3
If cell3.value = "-" Then
cell3.Value = Range("Sheet1!A2:A6").Cells(i, 1).Value
i = i +1
End If
Next
Next i
 
Upvote 0
Solution

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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