Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating a new worksheet by checking for blank values in a range

Hello, I am trying to create a new worksheet from an existing range of
data (pivot table copy/pasted values). This idea is to scan this range
and identify where there are no, or blank, values in a cell and return
take the heading (row and column) value for the blank cell and paste
them into a new worksheet for each occurrance. I have an example below
with A through C as column headings and 1 through 3 as row headings....

A B C
1 4 5 6
2 4 6
3 5

Using this example, I would want the new worksheet to populate as
such....

3 A
2 B
3 C

This is basically a tool to identify each area where there is missing
data and populate a new worksheet with those areas.

Can anyone help? This is beyond my programming capabilities, which are
quite modest.

Many Thanks!
Geoff

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Creating a new worksheet by checking for blank values in a range

Try this code:

Dim sh As Worksheet
Dim r As Range, rng As Range
Dim i As Integer

i = 1
Set rng = Selection ' get the selected range
Set sh = ActiveWorkbook.Sheets.Add ' add a new sheet
For Each r In rng 'iterate through all cells of rng
If r.Value = "" Then 'check if cell is empty
sh.Cells(i, 1).Value = r.Address ' write the empty cell address
in the new sheet
i = i + 1 'goto next row
End If
Next r


"Geoff" wrote:

Hello, I am trying to create a new worksheet from an existing range of
data (pivot table copy/pasted values). This idea is to scan this range
and identify where there are no, or blank, values in a cell and return
take the heading (row and column) value for the blank cell and paste
them into a new worksheet for each occurrance. I have an example below
with A through C as column headings and 1 through 3 as row headings....

A B C
1 4 5 6
2 4 6
3 5

Using this example, I would want the new worksheet to populate as
such....

3 A
2 B
3 C

This is basically a tool to identify each area where there is missing
data and populate a new worksheet with those areas.

Can anyone help? This is beyond my programming capabilities, which are
quite modest.

Many Thanks!
Geoff


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating a new worksheet by checking for blank values in a range

I believe you are on to something with that, but there is one
discrepancy.

The "headings" I was referring to are actual data in cells, not the
cell address. For instance, the columns are patient numbers (1-250)
and the rows are patient data (text such as Cycle1). Sorry for the
confusion. In an ideal world, the 1st column on the new spreadsheet
would contain the patient number corresponding to the blank cell and
the second column would contain the patient data corresponding to the
blank cell .

Thanks!!!
Geoff

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Creating a new worksheet by checking for blank values in a ran

Then try this:
Sub a()
Dim sh As Worksheet
Dim r As Range, rng As Range
Dim i As Integer

i = 1
Set rng = Selection ' get the selected range
Set sh = ActiveWorkbook.Sheets.Add ' add a new sheet
For Each r In rng 'iterate through all cells of rng
If r.Value = "" Then 'check if cell is empty
sh.Cells(i, 1).Value = rng(r.Row - 1, 0).Value ' write the cell
value at left of range in col1
sh.Cells(i, 2).Value = rng(0, r.Column - 1).Value ' write the
cell value at top of range to col2
i = i + 1 'goto next row
End If
Next r

End Sub

To get it working you select the data range(excluding header columns and
rows) and run the macro. Good Luck!

"Geoff" wrote:

I believe you are on to something with that, but there is one
discrepancy.

The "headings" I was referring to are actual data in cells, not the
cell address. For instance, the columns are patient numbers (1-250)
and the rows are patient data (text such as Cycle1). Sorry for the
confusion. In an ideal world, the 1st column on the new spreadsheet
would contain the patient number corresponding to the blank cell and
the second column would contain the patient data corresponding to the
blank cell .

Thanks!!!
Geoff


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating a new worksheet by checking for blank values in a ran

Excellent, all is working now! I did have to make a change to the
column and row indicators (r.Row - 3 and r.Column - 2) to get it to
work correctly. I have no idea why this is the case, I just messed
around with it until it worked. In any case, THANKS MARTIN!!! The new
code is below.........

Sub Reconcile()
Dim sh As Worksheet
Dim r As Range, rng As Range
Dim i As Integer

i = 1
Set rng = Selection
' get the selected range
Set sh = ActiveWorkbook.Sheets.Add
' add a new sheet
For Each r In rng
'iterate through all cells of rng
If r.Value = "" Then
'check if cell is empty
sh.Cells(i, 1).Value = rng(r.Row - 3, 0).Value
' write the cell value at left of range in col1
sh.Cells(i, 2).Value = rng(0, r.Column - 2).Value
' write the cell value at top of range to col2
i = i + 1
'goto next row
End If
Next r


End Sub



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
Checking for all blank cells in a range orcolumn. Mikey Excel Programming 1 June 30th 05 03:59 PM
Checking to See if Range Values Add up to 100 Paige Excel Programming 4 March 25th 05 12:01 AM
Checking ALL values in a range nospaminlich Excel Discussion (Misc queries) 13 February 10th 05 09:29 AM
checking if worksheet is blank Tommi[_2_] Excel Programming 1 November 2nd 03 03:59 PM
Checking if worksheet is blank Tommi[_2_] Excel Programming 3 October 31st 03 02:22 PM


All times are GMT +1. The time now is 11:13 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"