Macro cell reference help please

dangerousdaveeg

New Member
Joined
Mar 30, 2012
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
I have a spreadsheet with lots of data that is linked to other tabs in my spread sheet and I am looking for a way to copy a range of cells and then increase the reference in the pasted cells, so for example<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
I have data In Range “C3:C5” with references like<o:p></o:p>
<o:p> </o:p>
C3 - “='Raw Data'!A$4”<o:p></o:p>
C4 - “='Raw Data'!A$17”<o:p></o:p>
C5 – “='Raw Data'!A$30”<o:p></o:p>
<o:p> </o:p>
I might be missing something really obvious here but when I copy these three cells and paste them three cells down the reference does not change to “B” <o:p></o:p>
<o:p> </o:p>
I want the pasted cells to have <o:p></o:p>
<o:p> </o:p>
C6 - “='Raw Data'!B$4”,<o:p></o:p>
C7 - “='Raw Data'!B$17”<o:p></o:p>
C8 – “='Raw Data'!B$30”<o:p></o:p>
<o:p> </o:p>
I have to do this for every work day in the year so would prefer a macro that may make my life a lot easier, I have several macro’s in my workbook but this one I can’t seem to find no matter how much searching and testing I have tried.<o:p></o:p>
<o:p> </o:p>
So basically what I need is to<o:p></o:p>
Select range C3:C5<o:p></o:p>
Copy<o:p></o:p>
Move 3 cells down (which I can do)<o:p></o:p>
Paste (but increase the cell reference letter up one but keep row the same)<o:p></o:p>
 

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.
Considering you want to repeat it 365 times, this shall work:
Code:
Public Sub SetAddress()
Const csSheet As String = "'Raw Data'!" 'Change to suit
Dim lRow As Long, lCol As Long
    Range("C3").Formula = "=" & csSheet & "$A$4"
For i = 1 To 365
    lRow = 4 + (i Mod 3) * 13
    lCol = Int(i / 3) + 1
    Range("C" & i + 3).Formula = "=" & csSheet & Cells(lRow, lCol).Address
Next i
End Sub
 
Upvote 0
Try this.
Code:
Dim I As Long
Dim col As Long
For I = 1 To 365 Step 3
    col = col + 1
    Range("D" & I + 2).FormulaR1C1 = "='Raw Data'!R4C" & col
    Range("D" & I + 3).FormulaR1C1 = "='Raw Data'!R17C" & col
    Range("D" & I + 4).FormulaR1C1 = "='Raw Data'!R30C" & col
Next I
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

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