LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Query for Array !!!

First thing you need to do is get your own logic sorted out!!! You say
you want to 'flag' the last column with "wrong", but state the last col
as "G" of a 12 col array. (Doesn't make sense)

Here's how I might approach this task...

Sub Flag_NegativeValues()
Dim n&, rngData As Range, lLastCol&, lLastRow&

Set rngData = ActiveSheet.UsedRange
With rngData
lLastCol = .Columns.Count: lLastRow = .Rows.Count
End With 'rngData

With Application
For n = 1 To lLastRow
If .CountIf(.Index(rngData, n, 0), "<0") 0 Then
Cells(n, lLastCol + 1) = "wrong"
End If
Next 'n
End With 'Application
End Sub

...where I write directly to the sheet rather than rebuild an output
array that has to be written later. If you prefer to build an output
array then...

Sub Flag_NegativeValues2()
Dim vData, n&, lRows&, lCols&, rng As Range

Set rng = ActiveSheet.UsedRange: vData = rng
lRows = UBound(vData): lCols = UBound(vData, 2)
ReDim Preserve vData(1 To lRows, 1 To lCols + 1)

With Application
For n = LBound(vData) To UBound(vData)
If .CountIf(.Index(rng, n, 0), "<0") 0 Then
vData(n, UBound(vData, 2)) = "wrong"
End If
Next 'n
ActiveSheet.UsedRange.Resize(UBound(vData), UBound(vData, 2)) =
vData
End With 'Application
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
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
Web Query Results to an Array Raul Excel Programming 0 November 6th 08 04:12 PM
ARRAY QUERY JingleRock Excel Programming 4 September 23rd 07 04:42 PM
Array data in SQL Query? mazzarin Excel Programming 4 June 26th 06 08:07 PM
Web Query & Array Questions! gr8guy Excel Programming 1 August 25th 04 11:05 PM
Query for data in an array anonymous Excel Programming 2 January 13th 04 12:51 PM


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