Thread: arrays again
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_4_] Alan Beban[_4_] is offline
external usenet poster
 
Posts: 171
Default arrays again

I don't know about better, but here's a different way:

Sub testit2()
Dim Emptydat() As String
Dim iCols As Integer, iRows As Long
Dim rng1 As Range, rng2 As Range
Dim i As Integer, k As Integer, numBlanks As Integer
iCols = Range("iv2").End(xlToLeft).Column
iRows = Range("A65536").End(xlUp).Row
Set rng1 = Range(Cells(1, 1), Cells(1, iCols))
Set rng2 = Range(Cells(iRows, 1), Cells(iRows, iCols))
numBlanks = Application.CountIf(rng2, "")
ReDim Emptydat(1 To numBlanks)
k = 1
For i = 1 To iCols
If rng2(i) = "" Then
Emptydat(k) = rng1(i).Value
Debug.Print Emptydat(k)
k = k + 1
End If
Next
End Sub

Alan Beban

RobcPettit wrote:
Could somebody look at the following and advice if there is a better way to do:
Dim Emptydat()

Range("a65536").End(xlUp).Select
ActiveCell.Offset(1, 1).Select
n = Range("names").Count
Epicdat = Range("names")
Range(ActiveCell, ActiveCell.Offset(0, n)).Select
Blankdat = Selection
For B = 1 To n
If Blankdat(1, B) = "" Then
d = d + 1
ReDim Preserve Emptydat(1 To d)
Emptydat(d) = Epicdat(1, B)
End If
Next B

A B C D F
1 Title1 Title2 Title3 Title4
2 Date1 1 3 5 6
3 Date2 1 3 5 6
4 Date3 1 3 5 6
5 Date4 1 5 6


Bassically at the top of mysheet I have row 1 named 'names', about 200 col
wide, but this changes occasionally. In col 'A' I have dates going back 6 yrs
whence Im using ' Range("a65536").End(xlUp).Select' because this changes every
day. I then enter values beside each date, under each title in the 'names'
range. what I want to do with this program is from the last date in col a, is
check along the Row to see if there are any missing values, if so enter the
title of that col into an array, which Iater place in a worksheet. So in above
eg, C5 is blank, so I would enter Title2 into array.This program works perfect,
as Im using arrays I thought there may be a better way to use them.