excel

bkgashok
06-25-2010, 08:13 AM
hai,

pls consider the below code line

Range("B5") = "raju"


where the column b is the "name" column

now my question is can i use the column heading in the above code instead of "B"


i.e. i wish to change the line as Range("name5"), so that the cell of the 5th row in the name column will be replaced with "raju"

pls let me know the syntax for this if possible

i will be very much thank full for this solution

iabbott
06-29-2010, 05:19 AM
So cell B1 is "Name" and the rows below it contain names?

Do you want to enter a name, then automatically go down 1 line for the next name?

If so try this:
range("B1").select

Do
Activecell.Offset(1,0).Select

If Activecell.Value = "" Then
Activecell.Value = "raju" 'or set the new name to a variable so you will always add the latest name at the end
End If
Loop Until Activecell.Value = "raju"


This assumes you'll only enter that name once

If you want to add multiple names the same, then after Activecell.Value = "raju" above, add a line that says something like ExitLoop = 1, then change the code after Loop to say Until ExitLoop = 1

HaHoBe
06-29-2010, 11:07 AM
Hi, bkgashok,

if you know the number of the column:

With Columns(2)
.Cells(5).Value = "raju"
End With
Or youŽll serach for the keyword in Row1:

Dim rng As Range
Set rng = ActiveSheet.Rows(1).Find( _
what:="bkgashok", LookIn:=xlValues, lookat:=xlWhole, _
searchorder:=xlByRows)
If rng Is Nothing Then
Beep
Exit Sub
End If
With Columns(rng.Column)
.Cells(5).Value = "raju"
End With
Ciao,
Holger

bkgashok
06-30-2010, 10:40 AM
thanks friend,

it is working....

ashok

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum