Need column name

Closed
manish - Jun 17, 2009 at 08:36 AM
Excelguru Posts 261 Registration date Saturday April 11, 2009 Status Member Last seen June 21, 2011 - Jun 17, 2009 at 10:38 AM
Hello,

can anyone help me in the code given below.

i want column name in place of offset.what is the specific function to give column name.

For ZIP
If ActiveCell.Offset(0, 5).Value = "" Then
ActiveCell.Offset(0, 5).Value = 99999
End If
' For B
If ActiveCell.Offset(0, 6).Value = "" Then
ActiveCell.Offset(0, 6).Value = 0
End If
' For C
If ActiveCell.Offset(0, 7).Value = "" Then
ActiveCell.Offset(0, 7).Value = 0
End If
' For BI
If ActiveCell.Offset(0, 8).Value = "" Then
ActiveCell.Offset(0, 8).Value = 0
End If
' For TIV
If ActiveCell.Offset(0, 9).Value = "" Then
ActiveCell.Offset(0, 9).Value = 0
End If
' For CONST
If ActiveCell.Offset(0, 10).Value = "" Then
ActiveCell.Offset(0, 10).Value = 0
End If
' For YEAR
If ActiveCell.Offset(0, 11).Value = "" Then
ActiveCell.Offset(0, 11).Value = 9999
End If
' For FL
If ActiveCell.Offset(0, 12).Value = "" Then
ActiveCell.Offset(0, 12).Value = 0
End If
' For OCC
If ActiveCell.Offset(0, 13).Value = "" Then
ActiveCell.Offset(0, 13).Value = 0
End If
' For SQFT
If ActiveCell.Offset(0, 14).Value = "" Then
ActiveCell.Offset(0, 14).Value = 0
End If
' For COUNTRY
If ActiveCell.Offset(0, 18).Value = "" Then
ActiveCell.Offset(0, 18).Value = "USA"
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub

1 response

Excelguru Posts 261 Registration date Saturday April 11, 2009 Status Member Last seen June 21, 2011 307
Jun 17, 2009 at 10:38 AM
Hi Manish

If the column name is in row 1, you can access it using
cells(1,activecell.column).value

Let me know whether this helps...
0