# Thread: Slide over and fill down Thanks: 0 Likes: 0

1. ## Slide over and fill down

What is the best way to tackle this? Hoping the image conveys my problem well enough that my words and ignorance won't get in the way. Simply trying to create a CSV for borehole data. 1st number is the borehole number. It needs to be copied down for each layer of the borehole. 2nd and 3rd are the coordinates, they also need to go to column B & C for each layer of the borehole....then I need to do it again for the next borehole. Hoping to do this with VBA.

2. ## Re: Slide over and fill down

Hi there,

Could you post some sample before and after data, using one of these methods?

To post sample data:
Excel Jeanie
Or
TO CONTACT RICHARD
Richard Schollar's HTML Maker
OR TO DOWNLOAD EITHER HTMLMaker (Richard's table maker) or VBHTMLMAKER (code) IN OLDER BROWSER
https://skydrive.live.com/?cid=8cffd...813!189&brby=1

Or
Borders;Copy;Paste

Mark

3. ## Re: Slide over and fill down

Does this do what you want?

Sub Sort_Bore_Data()
'
Range("E65000").Select
Selection.End(xlUp).Select
LastLine = ActiveCell.Row

i = 1
Do While (i < LastLine)
If (Cells(i, 5).Value = "Latitude") Then
Cells(i + 2, 1).Value = Cells(i - 1, 5).Value
Cells(i + 2, 2).Value = Cells(i, 6).Value
Cells(i + 2, 3).Value = Cells(i + 1, 6).Value
Range(Rows(i - 1), Rows(i + 1)).Delete shift:=xlUp
LastLine = LastLine - 3
i = 0
End If
i = i + 1
Loop
End Sub

4. ## Re: Slide over and fill down

That is great. It's a step closer to what I need. I need those values filled down for each layer of the borehole. So A:4 through A:11 would be 10, B:4 through B:11 would be the lat and C:4 through C:11 would be the long. I realize my words or picture didn't convey that very well...but I'm a step closer to what I need, and the fill down should be simpler for me to wrap my head around. Thank you.

5. ## Re: Slide over and fill down

So you mean this?

Sub Sort_Bore_Data()
'
Range("E65000").Select
Selection.End(xlUp).Select
LastLine = ActiveCell.Row

i = 1
Do While (i < LastLine)
If (Cells(i, 5).Value = "Latitude") Then
Range(Cells(i + 2, 1), Cells(i + 10, 1)).Value = Cells(i - 1, 5).Value
Range(Cells(i + 2, 2), Cells(i + 10, 2)).Value = Cells(i, 6).Value
Range(Cells(i + 2, 3), Cells(i + 10, 3)).Value = Cells(i + 1, 6).Value

' Range(Rows(i - 1), Rows(i + 1)).Delete shift:=xlUp
Rows(i - 1).ClearContents
Range(Rows(i), Rows(i + 1)).Delete shift:=xlUp

LastLine = LastLine - 3
i = 0
End If
i = i + 1
Loop
End Sub

I added a space between sets so you can see them but if you don't want that then remove the single quote to the left of line 14 and delete the next two lines.

Regards

6. ## Re: Slide over and fill down

Thank you. Good stuff.

## User Tag List

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•