Help creating temporary worksheets
My code this isn't working.
Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name = "TempSheet"
does creates a new worksheet but it doesn't add the row to the sheet. I
would need something like...
Dim rng As Range
Dim cell As Range
Dim strTempValue As String
Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name = "TempSheet"
Set rng = Intersect(Range("R:R"), ActiveSheet.UsedRange)
For Each cell In rng
strTempValue = (cell.Value)
If strTempValue = "2" Then
'Copy entire row to "TempSheet" ......
End If
Next cell
'Call email routine
'Delete this TempSheet
I don't know how to ...
- Copy the row to the tempsheet
- Delete the tempsheet
- keep my original worksheet the ACTIVEsheet so I can use this same code
and run through it again testing for a different number.
Thanks.
"Saucer Man" wrote in message
...
Hi.
How's this?
Dim rng As Range
Dim cell As Range
Dim strTempValue As String
Set rng = Intersect(Range("R:R"), ActiveSheet.UsedRange)
For Each cell In rng
strTempValue = (cell.Value)
If strTempValue = "2" Then 'Number to test
Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name
= "TempSheet"
End If
Next cell
Will this create a temporary worksheet called "TempSheet" with a copy of
the every entire row it found with "2" in column R?
Will my original sheet still be the Active.Sheet so I can run through this
again later on testing for a different number in column R or does this new
tempsheet become the activesheet?
Thanks.
"Mike H" wrote in message
...
Hi,
Try this
Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name = "TempSheet"
Mike
"Saucer Man" wrote:
I am trying to create several temporary worksheets based on column data
in
my active sheet. I want to check each row in column R and if a certain
number is in the cell, add that row to a temporary sheet.
I will then be emailing that temporary sheet and deleting the temporary
file. Then I want to search my original active sheet again for a
different
number in that cell. I will be doing this about 20 times. I know how
to
email these sheets and delete them but I don't know how to create the
temporary sheets.
--
Thanks!
|