Please correct my macro

F

famdamly

My understanding of vb is not very good.


If ActiveCell.Column = t Then ActiveCell.Offset(0, -1).Text = "25"
else ActiveCell.Offset(0, 1).Text = "25"


I have a button between two columns in the center of the screen. I want
the user the to select a cell from one of the two columns, then select
from one of the buttons in between the columns that will assign a value
to the cell on the outside of each column.
 
A

Arvi Laanemets

Hi


If ActiveCell.Column = t Then
ActiveCell.Offset(0, -1).Text = "25"
Else
ActiveCell.Offset(0, 1).Text = "25"
End If

, or
ActiveCell.Offset(0, Iif(ActiveCell.Column = t,-1,1)).Text ="25"


Arvi Laanemets
 
F

famdamly

Thanks, I tried each of those and each brings back a run time error 424
object required.
 
A

Arvi Laanemets

Hi

The 't' in your formula is a column label, not a variable? Then

If ActiveCell.Column = 20 Then
ActiveCell.Offset(0, -1).Text = "25"
Else
ActiveCell.Offset(0, 1).Text = "25"
End If

, or
ActiveCell.Offset(0, Iif(ActiveCell.Column = 20,-1,1)).Text ="25"


Arvi Laanemets
 
F

famdamly

I kind of thought that might have something to do with it.

Thank you very much for your help.
 
Top