Filling Data in Columns
Filling Data in Columns
(OP)
I' m having difficulty generating the required code to perform what seems to be quite a simple operation.
I have imported a report (text file) into excel with data in column (names) and in column B (other personal details). I want to create some code that will enable me to copy down the name data into all the blank cells so that each piece of the individuals personal data has the person’s name in column A.
Example
ColumnA ColumnB
A Jones 8, Owen Place
Physics Department
01234 34422
B Jones 9, Owen Place
Biology
I need
ColumnA ColumnB
A Jones 8, Owen Place
A Jones Physics Department
A Jones 01234 34422
B Jones 9, Owen Place
B Jones Biology
As above the number of rows taken up by the personal details column is different for each individual hence I can not just loop through my imported file picking up the names and pasting down at regular intervals.
A more able mind in the realm of visual basic programming would be most appreciated.
I have imported a report (text file) into excel with data in column (names) and in column B (other personal details). I want to create some code that will enable me to copy down the name data into all the blank cells so that each piece of the individuals personal data has the person’s name in column A.
Example
ColumnA ColumnB
A Jones 8, Owen Place
Physics Department
01234 34422
B Jones 9, Owen Place
Biology
I need
ColumnA ColumnB
A Jones 8, Owen Place
A Jones Physics Department
A Jones 01234 34422
B Jones 9, Owen Place
B Jones Biology
As above the number of rows taken up by the personal details column is different for each individual hence I can not just loop through my imported file picking up the names and pasting down at regular intervals.
A more able mind in the realm of visual basic programming would be most appreciated.
RE: Filling Data in Columns
For example:
Dim i as integer 'Just the loop counter
While Not wSheet.cells(i,2).Value = ""
If wSheet.Cells(i,1).Value = "" Then
wSheet.Cells(i,1).Value = wSheet.Cells(i-1,1).Value
End If
i = i + 1
Wend
In english:
While column "B" has sometext
If Column "A" is empty then give it the same Value as the cell above it.
Check next row.
Hope this helps and that i've explained myself properly.
You made need to fiddle with this code a bit to fit it into your application.
Cheers,
hojo