selecting the cell to the right

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
how can i select the cell to the right in a macro?? i want to runa command in the cell to the right of the one i'm in after a caommand has taken place there

i.e.

1st command run in col b following by selcting the col c and running another command there

thanks everyone!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Code:
ActiveCell.Offset(0, 1).Select

but you do not need to Select a cell to work with it.
 
Upvote 0

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
ok then maybe you can help me. i have a command which types "successful" into col B, i need to select col C directly next to it and have it type the formula "=lastauthor()" into it.

the last author command is pre-setup so it should populate with the info when typed!
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Assuming that the cell in column B is the active cell then try

Code:
ActiveCell.Offset(0, 1).Formula = "=lastauthor()"
 
Upvote 0

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
if it isnt how can i ensure that the cell is the active one?

i.e. at the end of the macro command which works on that cell in col b can i put a command which keeps active there?
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Please can you post your code, or at least the part that puts "successful" in column B.
 
Upvote 0

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
sure:

Sheets("log").Select
LR = Cells(Rows.Count, "B").End(xlUp).Row
Cells(LR, "B").Value = "Successful"

I NEED THE COMMAND HERE!

End Sub
 
Upvote 0

northwolves

Well-known Member
Joined
Jun 21, 2006
Messages
1,128
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
  6. 2007
  7. 2003 or older
Platform
  1. Windows
Code:
Sub macro1()
If ActiveCell.Column = 2 Then ActiveCell.Offset(0, 1).Formula = "=lastauthor()"
End Sub

Best Regards
 
Upvote 0

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
Sheets("log").Select
LR = Cells(Rows.Count, "B").End(xlUp).Row
Cells(LR, "B").Value = "Successful"

I NEED THE CODE HERE thank you

End Sub
 
Upvote 0

Forum statistics

Threads
1,190,959
Messages
5,983,848
Members
439,867
Latest member
Shadrack

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
Top