PDA

View Full Version : Adjusting my code:to fill only empty rows



almouchie
01-17-2006, 04:11 AM
I have this code (provided by a helpful member) to read data in sevral workbooks & update the data in my main database workbook




Sub GetData()

Dim TgtCol
Dim Source
Dim Data

TgtCol = Array(2, 3, 5, 7, 9)
Source = Array("B1", "B2", "B3", "D7", "E7")
Workbooks.Open Filename:="C:\AAA\" & ActiveCell & ".xls"
Data = Array(Range(Source(0)), Range(Source(1)), Range(Source(2)), _
Range(Source(3)), Range(Source(4)))
Windows("database.xls").Activate
Sheets("database").Activate
For i = 0 To UBound(TgtCol)
Cells(ActiveCell.Row, TgtCol(i)) = Data(i)
Next

End Sub

I want to be able to run the code for only the rows that are blanks in my main sheet & not enter the same data every time

my workbook names are found in column B
i dont want the code to run all previous workbooks & enter the data
just the ones that are empty
for instance when cells in column C are blank to run the code

thanks