Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default VLOOKUP PART 2....(Dave Paterson)

The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I replace "sheet1"
with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VLOOKUP PART 2....(Dave Paterson)

You're not doing anything wrong...

But if you want to run the macro against the activesheet, then you can make sure
the correct worksheet is selected and change this line:

With Worksheets("sheet1").Range("a:a")
to
with activesheet.range("a:a")

wayne wrote:

The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I replace "sheet1"
with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VLOOKUP PART 2....(Dave Paterson)

Peterson. Dave Peterson.
(said in a Sean Connery voice.)


wayne wrote:

The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I replace "sheet1"
with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default VLOOKUP PART 2....(Dave Paterson)

"Money Penny give dave a big pat on the back...."



-----Original Message-----
Peterson. Dave Peterson.
(said in a Sean Connery voice.)


wayne wrote:

The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I

replace "sheet1"
with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub


--

Dave Peterson

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VLOOKUP PART 2....(Dave Paterson)

James Bond: I thought you might enjoy one of these.
[gives Ms. Moneypenny a cigar]
Ms. Moneypenny: How romantic. I know exactly where to put that.
[throws the cigar in the garbage]
James Bond: Oh Moneypenny, the story of our relationship: close, but no cigar.

http://www.imdb.com/title/tt0143145/quotes

wayne wrote:

"Money Penny give dave a big pat on the back...."

-----Original Message-----
Peterson. Dave Peterson.
(said in a Sean Connery voice.)


wayne wrote:

The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I

replace "sheet1"
with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub


--

Dave Peterson

.


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default VLOOKUP PART 2....(Dave Paterson)

"Ah yes, the legendary 007 wit, or at least half of it."

Dave Peterson wrote:
James Bond: I thought you might enjoy one of these.
[gives Ms. Moneypenny a cigar]
Ms. Moneypenny: How romantic. I know exactly where to put that.
[throws the cigar in the garbage]
James Bond: Oh Moneypenny, the story of our relationship: close, but no cigar.

http://www.imdb.com/title/tt0143145/quotes

wayne wrote:

"Money Penny give dave a big pat on the back...."


-----Original Message-----
Peterson. Dave Peterson.
(said in a Sean Connery voice.)


wayne wrote:

The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I

replace "sheet1"

with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub

--

Dave Peterson

.





--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VLOOKUP PART 2....(Dave Paterson)

Just in case people see that as an insensitive remark:

[After Q introduces Bond to his successor]
James Bond: If you're Q, does that make him R?
R: Ah yes, the legendary 007 wit, or at least half of it.

On the other hand, you may not have been quoting!!!!

(hehehe)

Debra Dalgleish wrote:

"Ah yes, the legendary 007 wit, or at least half of it."

Dave Peterson wrote:
James Bond: I thought you might enjoy one of these.
[gives Ms. Moneypenny a cigar]
Ms. Moneypenny: How romantic. I know exactly where to put that.
[throws the cigar in the garbage]
James Bond: Oh Moneypenny, the story of our relationship: close, but no cigar.

http://www.imdb.com/title/tt0143145/quotes

wayne wrote:

"Money Penny give dave a big pat on the back...."


-----Original Message-----
Peterson. Dave Peterson.
(said in a Sean Connery voice.)


<<snipped
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VLOOKUP PART 2....(Dave Paterson)

If you want to use the code name of the sheet

With Sheet1.Range("a:a")

Worksheets uses the tab name - so when you supply "sheet1" to that, it is
looking for a sheet with sheet1 as the tab name.

If you lose your code example, you can find it in help under the findnext
help example.


--
regards,
Tom Ogilvy

"wayne" wrote in message
...
The folowing code was supplied by Dave Paterson....Many
Thanks

I Can only get this code to work when I replace "sheet1"
with the actual sheet tab name ie "BOM Summary file1"
As the "sheet tab name" changes for each job / file why
shouldn't "Sheet1" overide the tab name????

Am I doing something wrong???

Option Explicit
Sub testme01()
Dim FoundCell As Range
Dim FirstAddress As String
Dim FindWhat As String

FindWhat = "109000"

With Worksheets("sheet1").Range("a:a")
Set FoundCell = .Cells.Find(what:=FindWhat, _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, lookat:=xlWhole)

If FoundCell Is Nothing Then
'do nothing
Else

FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Value = 0
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub




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
Vlookup with part match Rob Excel Worksheet Functions 5 December 13th 09 05:07 PM
Dave phlogiston appears in spreadsheet cell when I type Dave P tallsaint Excel Discussion (Misc queries) 2 September 4th 09 11:05 AM
Part of VLOOKUP not working Code Numpty Excel Worksheet Functions 4 December 10th 08 02:05 PM
Question for dave Paterson capt Excel Discussion (Misc queries) 8 February 28th 08 12:20 AM
Vlookup for part of a word jenhow Excel Worksheet Functions 7 April 29th 05 10:22 PM


All times are GMT +1. The time now is 02:52 AM.

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

About Us

"It's about Microsoft Excel"