View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
gmorris[_17_] gmorris[_17_] is offline
external usenet poster
 
Posts: 1
Default Conditional copy from multiple sheets to one sheet


Well, I tried this code and didn't have much success with it either. I
have all of the options on to make sure that variables are declared and
such (VERY important), so I got numerous errors until I changed it to
this:
Sub findblanks()

Dim Segment As Range, NewSht As Excel.Worksheet
Dim NewRowCount As Integer, sht As Excel.Worksheet
Dim SearchRange As Range
Dim RowCount As Integer, ColCount As Integer

Set Segment = Range("A1:D15")
Set NewSht = Sheets.Add(after:=Sheets(Sheets.Count))
NewSht.Name = "Blanks"
NewRowCount = 1
For Each sht In Sheets
If sht.Name < "Blanks" Then
Set SearchRange = Segment
For RowCount = 1 To SearchRange.Rows.Count
For ColCount = 1 To SearchRange.Columns.Count
If SearchRange.Cells(RowCount, ColCount) = "" Then
SearchRange.Rows(RowCount).Copy
Destination:=NewSht.Rows(NewRowCount)
NewRowCount = NewRowCount + 1
Exit For
End If
Next ColCount
Next RowCount
End If
Next sht

End Sub

Not sure why people don't want to Dim their vars, but even that didn't
work like you are wanting (at least I don't think so). It filled out the
entire worksheet with the same sets of data for some reason. I'll have
to look into it some more to figure out why...


--
gmorris
------------------------------------------------------------------------
gmorris's Profile: http://www.thecodecage.com/forumz/member.php?userid=245
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=91772