Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Work around to SpecialCells(xlCellTypeBlanks)...

Hey guys

I'm trying to find a work around to the following problem.
I'm trying to merge the data from numerous sheets into one sheet.

I can copy the data into one sheet, but am trying to eliminate blank rows.

I've used the VB code below, but beacuse the rows all contain formulas, the
'SpecialCells(xlCellTypeBlanks)' doesn't evaluate these cells as blank:

Code:
Sheets(combinedEMParams).Range("A2:D" & Range("D" &
Rows.Count).End(xlUp).Row).SpecialCells(xlCellType Blanks).EntireRow.Delete


Is there a 'xlCellTypeValueBlank' or something similar?

Thanks for your help
Dan


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 360
Default Work around to SpecialCells(xlCellTypeBlanks)...

You could try converting your formulas that don't return anything to
blanks first...

Sub Macro1()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If c.Text = "" Then c.Formula = ""
Next
End Sub

Cliff Edwards
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Work around to SpecialCells(xlCellTypeBlanks)...

Thanks for the reply mate, I could do that.

I've just thought though, If I get the VB code to check the value of a
single column to base my deletion on, I could get it to work.

But, how can I set the value of a cell, say A1, from a formula in cell D1?



"ward376" wrote:

You could try converting your formulas that don't return anything to
blanks first...

Sub Macro1()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If c.Text = "" Then c.Formula = ""
Next
End Sub

Cliff Edwards

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Work around to SpecialCells(xlCellTypeBlanks)...

Hi Dan,

I'm assuming that the cells with formulas appear blank because they display
"", is that correct? If so

Assume that you can tell if the row is to be removed because column B is
blank.

1. In an empty column enter the following formula =1/COUNTBLANK(B1) it will
return #DIV/0! on all non-blank rows.

2. Copy this down as far as necessary.
3. With these formula selected press F5 (or Ctrl_G), Special, Formulas, and
uncheck everything Errors.
This will select all the cells in the column containing 1.
4. Press Ctrl- (Ctrl + Minus) and choose Entire Row.

You can record all of this for your macro.

--
Cheers,
Shane Devenshire


"DanF" wrote:

Hey guys

I'm trying to find a work around to the following problem.
I'm trying to merge the data from numerous sheets into one sheet.

I can copy the data into one sheet, but am trying to eliminate blank rows.

I've used the VB code below, but beacuse the rows all contain formulas, the
'SpecialCells(xlCellTypeBlanks)' doesn't evaluate these cells as blank:

Code:
Sheets(combinedEMParams).Range("A2:D" & Range("D" &
Rows.Count).End(xlUp).Row).SpecialCells(xlCellType Blanks).EntireRow.Delete


Is there a 'xlCellTypeValueBlank' or something similar?

Thanks for your help
Dan


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 360
Default Work around to SpecialCells(xlCellTypeBlanks)...

Is column d the one you want to evaluate to determine if the row
should be deleted?

Cliff Edwards






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 360
Default Work around to SpecialCells(xlCellTypeBlanks)...

Sub remove()
Dim c As Range
For Each c In ActiveSheet.Range("d2:d" & Rows.Count)
If c.Text = "" Then c.EntireRow.Delete
Next
End Sub

Cliff Edwards
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Work around to SpecialCells(xlCellTypeBlanks)...

Hi Shane

Thanks a lot for the advice, will have a play!

Ta

"ShaneDevenshire" wrote:

Hi Dan,

I'm assuming that the cells with formulas appear blank because they display
"", is that correct? If so

Assume that you can tell if the row is to be removed because column B is
blank.

1. In an empty column enter the following formula =1/COUNTBLANK(B1) it will
return #DIV/0! on all non-blank rows.

2. Copy this down as far as necessary.
3. With these formula selected press F5 (or Ctrl_G), Special, Formulas, and
uncheck everything Errors.
This will select all the cells in the column containing 1.
4. Press Ctrl- (Ctrl + Minus) and choose Entire Row.

You can record all of this for your macro.

--
Cheers,
Shane Devenshire


"DanF" wrote:

Hey guys

I'm trying to find a work around to the following problem.
I'm trying to merge the data from numerous sheets into one sheet.

I can copy the data into one sheet, but am trying to eliminate blank rows.

I've used the VB code below, but beacuse the rows all contain formulas, the
'SpecialCells(xlCellTypeBlanks)' doesn't evaluate these cells as blank:

Code:
Sheets(combinedEMParams).Range("A2:D" & Range("D" &
Rows.Count).End(xlUp).Row).SpecialCells(xlCellType Blanks).EntireRow.Delete


Is there a 'xlCellTypeValueBlank' or something similar?

Thanks for your help
Dan


  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Work around to SpecialCells(xlCellTypeBlanks)...

Hi Cliff

Thanks for that, I'm got another idea from another fella as well, so I'm
gonna give both ideas a try.

Thanks for your time!

"ward376" wrote:

Sub remove()
Dim c As Range
For Each c In ActiveSheet.Range("d2:d" & Rows.Count)
If c.Text = "" Then c.EntireRow.Delete
Next
End Sub

Cliff Edwards

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
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Specialcells Bruno Uato Charts and Charting in Excel 0 October 7th 05 07:42 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM
VBA ON ERROR does not work with SPECIALCELLS Felix Excel Discussion (Misc queries) 2 April 14th 05 10:43 PM
Spin button in a work sheet - how do I make it work? [email protected] Excel Worksheet Functions 1 April 7th 05 08:43 PM


All times are GMT +1. The time now is 02:08 AM.

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

About Us

"It's about Microsoft Excel"