Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Im stuck again... Meader Excel Discussion (Misc queries) 2 May 29th 07 01:23 AM
Im stuck in VB! D[_6_] Excel Programming 5 August 11th 04 12:38 AM
Ok now im stuck Jonathan Excel Programming 2 June 29th 04 01:06 PM
I am new to VBA and am stuck djsmithuk123 Excel Programming 2 December 12th 03 02:13 PM
Still Stuck Josh in Tampa Excel Programming 9 October 28th 03 05:15 AM


All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"