Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Deleting blank cells globally

Hi, I have a 20x20 matrix of either non-zero values or "blanks" ("") that are
not constants--these cells have formulas.

I'd appreciate some assistance creating a macro that will systematically
traverse the matrix and delete cells (moving remaining cells up) that have
either a blank or some other non-number value.

The result should be 20 columns starting at, say, row 0, where each column
has up to 20 numbers, in original sequence, minus "blanks".

It could be done in-place if possible or somewhere else in the workbook.
Thanks in advance for the help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Deleting blank cells globally

Try the macro below...
It assumes your data starts at A1... i.e. Cells(i,j) with i=1, k=1
it writes out the values at A25 i.e. Cells(l,k) with l=25, k=1
You may change these values as per your requirment
It works on the activesheet

Sub deleteBlanks()
With ActiveSheet
l = 25
K = 1
For i = 1 To 20
For j = 1 To 20
If .Cells(i, j) < "" Then
.Cells(l, K) = .Cells(i, j)
If K = 20 Then
K = 1
l = l + 1
Else
K = K + 1
End If
End If
Next j
Next i
End With
End Sub


"MrHanky" wrote:

Hi, I have a 20x20 matrix of either non-zero values or "blanks" ("") that are
not constants--these cells have formulas.

I'd appreciate some assistance creating a macro that will systematically
traverse the matrix and delete cells (moving remaining cells up) that have
either a blank or some other non-number value.

The result should be 20 columns starting at, say, row 0, where each column
has up to 20 numbers, in original sequence, minus "blanks".

It could be done in-place if possible or somewhere else in the workbook.
Thanks in advance for the help

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Deleting blank cells globally

Suggested macro will only remove blanks.
You can use ISNUMBER to adapt it to your needs.
Let me know if you want me to do that.

"MrHanky" wrote:

Hi, I have a 20x20 matrix of either non-zero values or "blanks" ("") that are
not constants--these cells have formulas.

I'd appreciate some assistance creating a macro that will systematically
traverse the matrix and delete cells (moving remaining cells up) that have
either a blank or some other non-number value.

The result should be 20 columns starting at, say, row 0, where each column
has up to 20 numbers, in original sequence, minus "blanks".

It could be done in-place if possible or somewhere else in the workbook.
Thanks in advance for the help

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 793
Default Deleting blank cells globally

Try
Sub deleteBlanks()
With ActiveSheet
l = 25
K = 1
For i = 1 To 20
For j = 1 To 20
If IsNumeric(.Cells(i, j)) And .Cells(i, j) < 0 Then
.Cells(l, K) = .Cells(i, j)
If K = 20 Then
K = 1
l = l + 1
Else
K = K + 1
End If
End If
Next j
Next i
End With
End Sub

"Sheeloo" wrote:

Suggested macro will only remove blanks.
You can use ISNUMBER to adapt it to your needs.
Let me know if you want me to do that.

"MrHanky" wrote:

Hi, I have a 20x20 matrix of either non-zero values or "blanks" ("") that are
not constants--these cells have formulas.

I'd appreciate some assistance creating a macro that will systematically
traverse the matrix and delete cells (moving remaining cells up) that have
either a blank or some other non-number value.

The result should be 20 columns starting at, say, row 0, where each column
has up to 20 numbers, in original sequence, minus "blanks".

It could be done in-place if possible or somewhere else in the workbook.
Thanks in advance for the help

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Deleting blank cells globally

Sheeloo

Probably not applicable in this particular instance but just for
info........

Before using isnumeric see this thread.

You could be surprised.

http://tinyurl.com/9to4ka


Gord Dibben MS Excel MVP

On Wed, 20 May 2009 21:24:01 -0700, Sheeloo
wrote:

Try
Sub deleteBlanks()
With ActiveSheet
l = 25
K = 1
For i = 1 To 20
For j = 1 To 20
If IsNumeric(.Cells(i, j)) And .Cells(i, j) < 0 Then
.Cells(l, K) = .Cells(i, j)
If K = 20 Then
K = 1
l = l + 1
Else
K = K + 1
End If
End If
Next j
Next i
End With
End Sub

"Sheeloo" wrote:

Suggested macro will only remove blanks.
You can use ISNUMBER to adapt it to your needs.
Let me know if you want me to do that.

"MrHanky" wrote:

Hi, I have a 20x20 matrix of either non-zero values or "blanks" ("") that are
not constants--these cells have formulas.

I'd appreciate some assistance creating a macro that will systematically
traverse the matrix and delete cells (moving remaining cells up) that have
either a blank or some other non-number value.

The result should be 20 columns starting at, say, row 0, where each column
has up to 20 numbers, in original sequence, minus "blanks".

It could be done in-place if possible or somewhere else in the workbook.
Thanks in advance for the help


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
Globally deleting part of the information in a cell JanetP Excel Worksheet Functions 4 November 19th 08 03:32 PM
Deleting blank cells AFTER an UNMERGE Troy Excel Discussion (Misc queries) 1 April 25th 08 09:12 PM
Deleting blank spaces in cells Mr Gow Excel Discussion (Misc queries) 4 May 17th 06 02:06 PM
Deleting Blank Cells Wholesale? Trey Excel Discussion (Misc queries) 1 October 6th 05 09:37 PM
Deleting blank cells in a column KatyLady Excel Discussion (Misc queries) 6 May 30th 05 03:47 PM


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