Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Vlookup with part match | Excel Worksheet Functions | |||
Dave phlogiston appears in spreadsheet cell when I type Dave P | Excel Discussion (Misc queries) | |||
Part of VLOOKUP not working | Excel Worksheet Functions | |||
Question for dave Paterson | Excel Discussion (Misc queries) | |||
Vlookup for part of a word | Excel Worksheet Functions |