I'm using Excel 2003. I have two tabs: AllTxt & ExtractInfo
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
> </o
>
In 'Alltxt', I need to find each occurence of ***. If found, I need to write the contents of that cell into tab "ExtractInfo".
<o
> </o
>
The *** could be in different columns (A, B, C, or D)
<o
> </o
>
I'm using ".find" and it does find it. Now I need to write it to ExtractInfo, but nothing seems to be working.
<o
> </o
>
My code:
AllTxtLastRow is a variable (long) and does contact the last row number in tab AllTxt
ExtInfoBlankRow is a variable (long) and does contain the last row in tab ExtractedInfo
<o
> </o
>
strTextToFind = "~***"
<o
> </o
>
With Sheets("AllTxt").Range("A1":D" & AllTxtLastRow)
<o
> </o
>
CheckNext:
<o
> </o
>
Set C = .Find(strTxtToFind, LookIn:=xlValues) '(this works)
<o
> </o
>
If Not C is Nothing then 'finds the ***
FoundAddress = C.Address 'this is correct, e.g., $B$40
FoundRow = C.Row 'foundrow contains the correct row, e.g., 40
FoundCol = C.Column 'foundcol contains the correct col, e.g, B
<o
> </o
>
' ==========================<o
></o
>
'I'VE TRIED ABOUT 15+ THINGS, NOTHING WORKS TO WRITE THE CONTENTS INTO EXTRACTINFO TAB<o
></o
>
' A FEW FOLLOW<o
></o
>
<o
></o
>
'this does work--I get 'subscript out of range'<o
></o
>
Contents = Sheets("ExtractInfo").Cells(FoundRow,FoundCol) <o
></o
>
<o
> </o
>
'this does not work--I get Application-defined or object-defined error<o
></o
>
Worksheets("ExtractInfo").Range("A" & ExtInfoBlankRow, "A"). value = Worksheets("AllTxt").Range(FoundRow, FoundCol).value<o
></o
>
' ==============================<o
></o
>
<o
> </o
>
ActiveCell.Offset(1,0).select 'move to the next row down
ExtInfoBlankRow = ExtInfoBlankRow + 1
Goto CheckNext
<o
> </o
>
Else
Goto GetNextFile
end if
end with
<o
> </o
>
GetNextFile:
<o
> </o
>
<o
> </o
>
<o
> </o
>
YOUR HELP WOULD BE SO APPRECIATED!
<o
> </o
>
<o
> </o
>
<o
> </o
>
<o
> </o
>
<o
> </o
>
<o
> </o
>
<o
> </o
>
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




In 'Alltxt', I need to find each occurence of ***. If found, I need to write the contents of that cell into tab "ExtractInfo".
<o


The *** could be in different columns (A, B, C, or D)
<o


I'm using ".find" and it does find it. Now I need to write it to ExtractInfo, but nothing seems to be working.
<o


My code:
AllTxtLastRow is a variable (long) and does contact the last row number in tab AllTxt
ExtInfoBlankRow is a variable (long) and does contain the last row in tab ExtractedInfo
<o


strTextToFind = "~***"
<o


With Sheets("AllTxt").Range("A1":D" & AllTxtLastRow)
<o


CheckNext:
<o


Set C = .Find(strTxtToFind, LookIn:=xlValues) '(this works)
<o


If Not C is Nothing then 'finds the ***
FoundAddress = C.Address 'this is correct, e.g., $B$40
FoundRow = C.Row 'foundrow contains the correct row, e.g., 40
FoundCol = C.Column 'foundcol contains the correct col, e.g, B
<o


' ==========================<o


'I'VE TRIED ABOUT 15+ THINGS, NOTHING WORKS TO WRITE THE CONTENTS INTO EXTRACTINFO TAB<o


' A FEW FOLLOW<o


<o


'this does work--I get 'subscript out of range'<o


Contents = Sheets("ExtractInfo").Cells(FoundRow,FoundCol) <o


<o


'this does not work--I get Application-defined or object-defined error<o


Worksheets("ExtractInfo").Range("A" & ExtInfoBlankRow, "A"). value = Worksheets("AllTxt").Range(FoundRow, FoundCol).value<o


' ==============================<o


<o


ActiveCell.Offset(1,0).select 'move to the next row down
ExtInfoBlankRow = ExtInfoBlankRow + 1
Goto CheckNext
<o


Else
Goto GetNextFile
end if
end with
<o


GetNextFile:
<o


<o


<o


YOUR HELP WOULD BE SO APPRECIATED!
<o


<o


<o


<o


<o


<o


<o

