Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default array question

was wondering if this was possible using an array.
i have lastrow set to i
i would like to set a variable to either column "A", "b" or "C" (col below)
so if any of the 3 columns in row i are blank, the row is deleted.
i know i can write some if's to handle it, just trying to gain some
practice with arrays.
linecount just tells me how many rows were deleted

col = (Array("A", "B", "C")) (i know this is wrong, just an example)
For i = lastrow To 1 Step -1

If Array(Cells(i, col)) = "" Then
Cells(i, col).EntireRow.Delete
LineCount = LineCount + 1
End If
Next
--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default array question

one way:

Dim i As Long
For i = lastrow To 1 Step -1
If Application.CountA(Cells(i, 1).Resize(1, 3)) = 0 Then
Rows(i).Delete
LineCount = LineCount + 1
End If
Next i




In article ,
"Gary Keramidas" wrote:

was wondering if this was possible using an array.
i have lastrow set to i
i would like to set a variable to either column "A", "b" or "C" (col below)
so if any of the 3 columns in row i are blank, the row is deleted.
i know i can write some if's to handle it, just trying to gain some
practice with arrays.
linecount just tells me how many rows were deleted

col = (Array("A", "B", "C")) (i know this is wrong, just an example)
For i = lastrow To 1 Step -1

If Array(Cells(i, col)) = "" Then
Cells(i, col).EntireRow.Delete
LineCount = LineCount + 1
End If
Next

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default array question

thanks je:

one question:

just curious, how do i know the CountA(Cells(i, 1).Resize(1, 3)) creates an
or condition?

--


Gary


"JE McGimpsey" wrote in message
...
one way:

Dim i As Long
For i = lastrow To 1 Step -1
If Application.CountA(Cells(i, 1).Resize(1, 3)) = 0 Then
Rows(i).Delete
LineCount = LineCount + 1
End If
Next i




In article ,
"Gary Keramidas" wrote:

was wondering if this was possible using an array.
i have lastrow set to i
i would like to set a variable to either column "A", "b" or "C" (col
below)
so if any of the 3 columns in row i are blank, the row is deleted.
i know i can write some if's to handle it, just trying to gain some
practice with arrays.
linecount just tells me how many rows were deleted

col = (Array("A", "B", "C")) (i know this is wrong, just an example)
For i = lastrow To 1 Step -1

If Array(Cells(i, col)) = "" Then
Cells(i, col).EntireRow.Delete
LineCount = LineCount + 1
End If
Next



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default array question

In article ,
"Gary Keramidas" wrote:

thanks je:

one question:

just curious, how do i know the CountA(Cells(i, 1).Resize(1, 3)) creates an
or condition?


It doesn't. It calls XL's COUNTA function for cells Ai:Ci. See COUNTA in
XL help to understand what it returns.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default array question

i changed this line
If Application.CountA(Cells(i, 1).Resize(1, 3)) = 0 Then
to
If Application.CountA(Cells(i, 1).Resize(1, 3)) <3 Then

there should be 3 non blank cells in each row from column a to c. if there
is less than 3, it deletes the row, which would equate to an "or" statement,
at least in my mind<g

i guess i could have changed the delete action line to do nothing if counta
= 0, too.


--


Gary


"JE McGimpsey" wrote in message
...
In article ,
"Gary Keramidas" wrote:

thanks je:

one question:

just curious, how do i know the CountA(Cells(i, 1).Resize(1, 3)) creates
an
or condition?


It doesn't. It calls XL's COUNTA function for cells Ai:Ci. See COUNTA in
XL help to understand what it returns.



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
Array Question keeblerjp Excel Discussion (Misc queries) 4 June 20th 06 04:21 PM
Array Question Renee Excel Worksheet Functions 0 June 29th 05 07:10 PM
Array Question Frederick Chow Excel Programming 3 March 10th 05 06:16 PM
Array question Jim Simpson Excel Programming 3 September 22nd 04 04:40 AM
Array Question andym Excel Programming 3 September 2nd 04 02:34 PM


All times are GMT +1. The time now is 01:20 PM.

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"