The_Rock
Board Regular
- Joined
- Jul 2, 2007
- Messages
- 174
Hi Folks
I'm trying to delve deeper into VBA and am trying to run the following macro without resorting to 'Select' or 'Activate'.
What I am trying is to get the macro to loop thru two different worksheets, enter a formula, then copy & paste it down to the length of the range.
What happens is that it enters the formula in the correct sheet, but when it has to copy and paste, it does so on the current page!
Appreciate your wisdom on this.
I'm trying to delve deeper into VBA and am trying to run the following macro without resorting to 'Select' or 'Activate'.
What I am trying is to get the macro to loop thru two different worksheets, enter a formula, then copy & paste it down to the length of the range.
What happens is that it enters the formula in the correct sheet, but when it has to copy and paste, it does so on the current page!
Appreciate your wisdom on this.
Code:
Sub Concat()
''Fill Concats in following sheets
Dim ws As Worksheet, rng As Range
Dim cpw As Worksheet
Set ws = Sheets("Missing Details - MPR")
Set cpw = Sheets("CHIP Pull (Website)")
'Missing Details - MPR
Set rng = ws.Range("A3")
Range("A3") = "=RC[1]&RC[2]&RC[3]"
rng.Copy Destination:=Range("A3:A" & Range("C" & Rows.Count).End(xlUp).Row)
Set rng = ws.Range("A4:A" & Range("C" & Rows.Count).End(xlUp).Row)
rng.Copy
rng.PasteSpecial (xlPasteValues)
'CHIP Pull (Website)
Set rng = cpw.Range("A2")
Range("A2") = "=RC[2]&RC[3]"
rng.Copy Destination:=Range("A2:A" & Range("C" & Rows.Count).End(xlUp).Row)
Set rng = cpw.Range("A3:A" & Range("C" & Rows.Count).End(xlUp).Row)
rng.Copy
rng.PasteSpecial (xlPasteValues)
End Sub