Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
I'm stuck (again)
Hi
I'm trying to write that if a variable equals a value then find a cell that equals the same amount and type in another variables value in to the cell next to it. Thanks Michael |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
I'm stuck (again)
Dim rng as Range
Dim myVar as Long myVar = 10 set rng = cells.find(10) if not rng is nothing then rng.offset(0,1).Value = 20 end if -- Regards, Tom Ogilvy "Himszy" wrote in message . .. Hi I'm trying to write that if a variable equals a value then find a cell that equals the same amount and type in another variables value in to the cell next to it. Thanks Michael |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
I'm stuck (again)
Michael
I think I understand, try and work this through Sub TwoVariables() Dim Var1 As Variant, Var2 As Variant Dim RFound As Range Var1 = "Nick" Var2 = "NotNick" Set RFound = Worksheets("Sheet1").Range("A1:A100").Find _ (Var1, LookIn:=xlValues) If Not RFound Is Nothing Then RFound.Offset(0, 1).Value = Var2 End If End Sub -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Himszy" wrote in message . .. Hi I'm trying to write that if a variable equals a value then find a cell that equals the same amount and type in another variables value in to the cell next to it. Thanks Michael |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
I'm stuck (again)
Not to be picky since this is excelent code, but I think that it should read...
set rng = cells.find(myVar) Tom you really write the nicest code... "Tom Ogilvy" wrote: Dim rng as Range Dim myVar as Long myVar = 10 set rng = cells.find(10) if not rng is nothing then rng.offset(0,1).Value = 20 end if -- Regards, Tom Ogilvy "Himszy" wrote in message . .. Hi I'm trying to write that if a variable equals a value then find a cell that equals the same amount and type in another variables value in to the cell next to it. Thanks Michael |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
I'm stuck (again)
Jim,
good catch, thanks. -- Regards, Tom Ogivy "Jim Thomlinson" wrote in message ... Not to be picky since this is excelent code, but I think that it should read... set rng = cells.find(myVar) Tom you really write the nicest code... "Tom Ogilvy" wrote: Dim rng as Range Dim myVar as Long myVar = 10 set rng = cells.find(10) if not rng is nothing then rng.offset(0,1).Value = 20 end if -- Regards, Tom Ogilvy "Himszy" wrote in message . .. Hi I'm trying to write that if a variable equals a value then find a cell that equals the same amount and type in another variables value in to the cell next to it. Thanks Michael |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
I'm stuck (again)
"Nick Hodge" wrote in message ... Michael I think I understand, try and work this through Sub TwoVariables() Dim Var1 As Variant, Var2 As Variant Dim RFound As Range Var1 = "Nick" Var2 = "NotNick" Set RFound = Worksheets("Sheet1").Range("A1:A100").Find _ (Var1, LookIn:=xlValues) If Not RFound Is Nothing Then RFound.Offset(0, 1).Value = Var2 End If End Sub -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Himszy" wrote in message . .. Hi I'm trying to write that if a variable equals a value then find a cell that equals the same amount and type in another variables value in to the cell next to it. Thanks Michael Thanks Tom, Jim and Nick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Im stuck again... | Excel Discussion (Misc queries) | |||
Im stuck in VB! | Excel Programming | |||
Ok now im stuck | Excel Programming | |||
I am new to VBA and am stuck | Excel Programming | |||
Still Stuck | Excel Programming |