Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling Data in Columns

Status
Not open for further replies.

cymru

Bioengineer
Jun 20, 2003
1
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.


 
Replies continue below

Recommended for you

Juat a thought as i have not tried this, but what if you have a loop that runs down your "A" column and if the cell is empty then it equals the cell above it, but only if there is data in column "B" otherwise it will run continuously.

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor