How to make a macro containing a relative cell rather then a specific cell

Daintel

New Member
Joined
Jul 7, 2011
Messages
6
Hello

First-time user to this site so I apologise if I appear to be a little clumsy.;)

I am using Excel 2010 and trying out some macros.

How do I make a macro containing a relative cell rather then a specific cell.

ie: When recording a macro, I wanted the macro to move to the start of the row but got the following code: Range("I32").Select because I was in "I32" when registring the macro. I wanted the macro to go to A32 if I was in row 32 or A33 if I am in row 33 etc...

Looking forward to hearing from one of you.
Best regards
Patrick
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
What macro do you have and what it does?
 
Upvote 0
Hi thanks for answering so fast.

This is the macro I have registered:


Range("I32").Select
ActiveCell.FormulaR1C1 = "9"
Application.Run "todo4.xlsm!SortByDate"


I would like to change it so that:

Range("I32").Select actually brings the cursor to the start of the row in which my cursor is currently standing.

so that:
ActiveCell.FormulaR1C1 = "9" actually brings the cursor to column "I" on the row in which my cursor is currently standing and enters "9" in the cell

Any suggestion?
 
Upvote 0
Woah thanks it works perfectly. :)

Could you also help me solve this:


ActiveCell.FormulaR1C1 = "9" should bring the cursor to column "I" on the row in which my cursor is currently standing then it should enter "9" in the cell.

Thanks a lot.
 
Upvote 0
Yes really great, we are nearly there :)

Then when the cursor is in column "I" , I would like that the macro enters the number "9" in the cell.

Thank you so much.
 
Upvote 0
Yes really great, we are nearly there :)

Then when the cursor is in column "I" , I would like that the macro enters the number "9" in the cell.

Thank you so much.

You are welcome
(i tried to edit my last post and lost it...)

try this

Rows(ActiveCell.Row).Cells(1,"I") = "9"

M.
 
Upvote 0
Hey,

You dont need the quotes to enter a number, simply enter 9 without quotes.

M.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

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