Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Finding empty cells

I have a workbook with 10 worksheets (tabs) each with a Header Row with the
month of July dates across the top and a Header Column with other
information running down the side. What macro would search all 10 sheets
for the last date (column) that might have an entry from any of the rows,
search back from there through July 1st and identify all blank cells or
cells with a red "fill" and consolidate all of them on a new worksheet?

Thanks for any help,

Brian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Finding empty cells

Sub combinesheets()

First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

I have a workbook with 10 worksheets (tabs) each with a Header Row with the
month of July dates across the top and a Header Column with other
information running down the side. What macro would search all 10 sheets
for the last date (column) that might have an entry from any of the rows,
search back from there through July 1st and identify all blank cells or
cells with a red "fill" and consolidate all of them on a new worksheet?

Thanks for any help,

Brian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Finding empty cells

Joel,

Thanks for the response. This is my first attempt at using a macro though!
I took your script and copied and pasted it in as a module. I then wnet to
"Tools", "Macros", saw the "Combinesheets" macro and hit "Run". It came
back though and said "Compile Error: Variable Not Defined" and the "First =
True" statement at the top was grayed out. Am I doing something wrong in
loading or execution?

Thanks,

Brian

"Joel" wrote in message
...
Sub combinesheets()

First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

I have a workbook with 10 worksheets (tabs) each with a Header Row with
the
month of July dates across the top and a Header Column with other
information running down the side. What macro would search all 10 sheets
for the last date (column) that might have an entry from any of the rows,
search back from there through July 1st and identify all blank cells or
cells with a red "fill" and consolidate all of them on a new worksheet?

Thanks for any help,

Brian





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Finding empty cells

Depending on the way your workbook is set up you are required to define
variables. My workbook doesn't. I added the definitaions below


Sub combinesheets()
Dim First As Boolean
Dim Sht As Sheets
Dim SummarySht As Sheets
Dim NewRow As Long
Dim LastCol As Long
Dim LastRow As Long
Dim AddedRow As Long


First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

Joel,

Thanks for the response. This is my first attempt at using a macro though!
I took your script and copied and pasted it in as a module. I then wnet to
"Tools", "Macros", saw the "Combinesheets" macro and hit "Run". It came
back though and said "Compile Error: Variable Not Defined" and the "First =
True" statement at the top was grayed out. Am I doing something wrong in
loading or execution?

Thanks,

Brian

"Joel" wrote in message
...
Sub combinesheets()

First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

I have a workbook with 10 worksheets (tabs) each with a Header Row with
the
month of July dates across the top and a Header Column with other
information running down the side. What macro would search all 10 sheets
for the last date (column) that might have an entry from any of the rows,
search back from there through July 1st and identify all blank cells or
cells with a red "fill" and consolidate all of them on a new worksheet?

Thanks for any help,

Brian






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Finding empty cells

I've tried this again but am still getting a Compile Error. Any suggestions
on maybe some settings I should change?

Thanks,

Brian


"Joel" wrote in message
...
Depending on the way your workbook is set up you are required to define
variables. My workbook doesn't. I added the definitaions below


Sub combinesheets()
Dim First As Boolean
Dim Sht As Sheets
Dim SummarySht As Sheets
Dim NewRow As Long
Dim LastCol As Long
Dim LastRow As Long
Dim AddedRow As Long


First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

Joel,

Thanks for the response. This is my first attempt at using a macro
though!
I took your script and copied and pasted it in as a module. I then wnet
to
"Tools", "Macros", saw the "Combinesheets" macro and hit "Run". It came
back though and said "Compile Error: Variable Not Defined" and the "First
=
True" statement at the top was grayed out. Am I doing something wrong in
loading or execution?

Thanks,

Brian

"Joel" wrote in message
...
Sub combinesheets()

First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

I have a workbook with 10 worksheets (tabs) each with a Header Row
with
the
month of July dates across the top and a Header Column with other
information running down the side. What macro would search all 10
sheets
for the last date (column) that might have an entry from any of the
rows,
search back from there through July 1st and identify all blank cells
or
cells with a red "fill" and consolidate all of them on a new
worksheet?

Thanks for any help,

Brian










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Finding empty cells

I left a colon out of one statment. If there are additional problems let me
know which line has the error. It willusually be highlighted. Excel 2003
didn't give me a compiler error, but the line needed to be fixed.


from
Sht.Rows(1).Copy Destination=SummarySht.Rows(1)
to
Sht.Rows(1).Copy Destination:=SummarySht.Rows(1)

"leimst" wrote:

I've tried this again but am still getting a Compile Error. Any suggestions
on maybe some settings I should change?

Thanks,

Brian


"Joel" wrote in message
...
Depending on the way your workbook is set up you are required to define
variables. My workbook doesn't. I added the definitaions below


Sub combinesheets()
Dim First As Boolean
Dim Sht As Sheets
Dim SummarySht As Sheets
Dim NewRow As Long
Dim LastCol As Long
Dim LastRow As Long
Dim AddedRow As Long


First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

Joel,

Thanks for the response. This is my first attempt at using a macro
though!
I took your script and copied and pasted it in as a module. I then wnet
to
"Tools", "Macros", saw the "Combinesheets" macro and hit "Run". It came
back though and said "Compile Error: Variable Not Defined" and the "First
=
True" statement at the top was grayed out. Am I doing something wrong in
loading or execution?

Thanks,

Brian

"Joel" wrote in message
...
Sub combinesheets()

First = True

For Each Sht In ThisWorkbook.Sheets
If First = True Then
'create new summary worksheet
Set SummarySht = Worksheets.Add(after:=Sheets(Sheets.Count))
'copy header Row to new sheet
Sht.Rows(1).Copy Destination = SummarySht.Rows(1)
NewRow = 2
First = False
End If
LastCol = Sht.Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = Sht.Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
AddedRow = False
For ColCount = 2 To LastCol
If Sht.Cells(RowCount, ColCount) = "" Or _
Sht.Cells(RowCount, ColCount). _
Interior.ColorIndex < xlNone Then

If AddedRow = False Then
'add header column
SummarySht.Range("A" & NewRow).Value = _
Sht.Range("A" & RowCount).Value
AddedRow = True
End If
If Sht.Cells(RowCount, ColCount) = "" Then
'Add X for empty cells
SummarySht.Cells(NewRow, ColCount) = "X"
Else
NewSht.Cells(RowCount, ColCount).Copy _
Destination:=SummarySht.Cells(NewRow, ColCount)
End If
End If
Next ColCount
If AddedRow = True Then
AddedRow = AddedRow + 1
End If
Next RowCount
Next Sht

End Sub


"leimst" wrote:

I have a workbook with 10 worksheets (tabs) each with a Header Row
with
the
month of July dates across the top and a Header Column with other
information running down the side. What macro would search all 10
sheets
for the last date (column) that might have an entry from any of the
rows,
search back from there through July 1st and identify all blank cells
or
cells with a red "fill" and consolidate all of them on a new
worksheet?

Thanks for any help,

Brian









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding data amongst empty cells James Excel Discussion (Misc queries) 6 November 10th 09 04:35 PM
Finding number of empty cells Floyd[_2_] Excel Programming 10 May 10th 06 03:00 AM
Finding Empty Cells Bill[_30_] Excel Programming 2 February 20th 06 01:41 PM
finding/highlighting empty cells Patrick[_4_] Excel Programming 1 October 1st 03 08:33 AM
Macro trouble finding 'empty' cells foamfollower Excel Programming 1 October 1st 03 02:59 AM


All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"