Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In , Ron Rosenfeld
spake thusly: On Fri, 10 Aug 2007 12:00:40 +0000 (UTC), Dallman Ross <dman@localhost. wrote: I have VBA code to run web queries on a set of sheets. I want to add an If-statement such that If Right(.Name,2) ... where the dots would finish the statement "is contained in Range("A1") of the first sheet in the series." You can use Instr to see if one string is contained within another. It will return zero (0) if it is not. Okay, that's cool help, Ron. Thank you. So now I have: For Each sh In ThisWorkbook.worksheets If Left(sh.Name, 12) = "Order Status" Then If InStr(5, Range("A1"), Right(sh.Name, 2)) 0 Then . . . That's working! Now I need to figure out telling it "but don't bother with this[1] if sh.Name ends in something that doesn't look like a number." Or maybe alternatively "but don't bother with this if this sheet's A1 cell doesn't have anything in it." (Both should have the same effect. I don't know which is easier to code.) [1] "Don't bother with this" means go ahead and do the query according to the parent If-statement, which succeeded. =dman= |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if not isemtpy(sh.Range("A1")) then
or if len(trim(sh.Range("A1")) < 0 then As to my previous post, I misread that the check should be made in the first column, not cell A1. -- Regards, Tom Ogilvy "Dallman Ross" wrote: In , Ron Rosenfeld spake thusly: On Fri, 10 Aug 2007 12:00:40 +0000 (UTC), Dallman Ross <dman@localhost. wrote: I have VBA code to run web queries on a set of sheets. I want to add an If-statement such that If Right(.Name,2) ... where the dots would finish the statement "is contained in Range("A1") of the first sheet in the series." You can use Instr to see if one string is contained within another. It will return zero (0) if it is not. Okay, that's cool help, Ron. Thank you. So now I have: For Each sh In ThisWorkbook.worksheets If Left(sh.Name, 12) = "Order Status" Then If InStr(5, Range("A1"), Right(sh.Name, 2)) 0 Then . . . That's working! Now I need to figure out telling it "but don't bother with this[1] if sh.Name ends in something that doesn't look like a number." Or maybe alternatively "but don't bother with this if this sheet's A1 cell doesn't have anything in it." (Both should have the same effect. I don't know which is easier to code.) [1] "Don't bother with this" means go ahead and do the query according to the parent If-statement, which succeeded. =dman= |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy text from cell to cell with one cell changing text | Excel Worksheet Functions | |||
Setting the text in a cell to the text of a cell on a different sheet in the same workbook | Excel Programming | |||
select text in cell based on text from another cell, paste the text at the begining of a thrid cell, etc... | Excel Programming | |||
Deleting Rows based on text in cell & formatting cell based on text in column beside it | Excel Programming | |||
extracting text from within a cell - 'text to rows@ equivalent of 'text to columns' | Excel Programming |