Question re a relative not absolute macro

alun

New Member
Joined
Nov 18, 2005
Messages
2
Hi

What I need to do is this on a macro

a) have excel change some numbers on this row
b) have excel change some numbers on the next row

when i've tried this it always changes the EXACT cell that i recorded it on.

in other words it acts absolutely not relatively.

So if I'm on row 12 I'll want it to alter F12 and D13, if i'm on row 18 I'll want it to alter F18 and D19.

Is this possible?

Many thanks

Al
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You can use ActiveCell.Row to refer to the row the cell is currently in:

Code:
Sub test()
Dim myRow As Long

myRow = ActiveCell.Row
Cells(myRow, "D").Value = "X"
Cells(myRow, "F").Value = "Y"

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,886
Messages
6,181,594
Members
453,056
Latest member
Jonasanas

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