View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Please Help. Macro - changing data layout

Sub Test()
Dim iLastRow As Long
Dim i As Long
Dim rng As Range
Dim sTemp As String

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If IsDate(Cells(i, "A").Value) Then
Cells(i, "A").Resize(, 2).Copy Cells(i, "B")
Cells(i, "A").Value = sTemp
Else
If rng Is Nothing Then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
If Cells(i, "A").Value < "" Then
sTemp = Cells(i, "A").Value
End If
End If
Next i

If Not rng Is Nothing Then rng.Delete

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"talkto_menow" wrote in message
ps.com...
am trying to import data to Access. Exported excel file has following
layout

Account_1

Date, Amount
Date, Amount


Account_2

Date, Amount
Date, Amount


I would like to move the Account cell value to different position, see
below


Account_1, Date, Amount
Account_1, Date, Amount


Account_2, Date, Amount
Account_2, Date, Amount


Is there any way to create VBA code that could do this for me?


Thanks