Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Please Help. Macro - changing data layout

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Please Help. Macro - changing data layout

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I switch from Office 2007 layout to the old 2003 layout? samanthajade Excel Discussion (Misc queries) 3 May 11th 08 09:40 PM
changing default page layout Anne Ryan Setting up and Configuration of Excel 1 March 2nd 07 04:00 PM
Changing the Layout of a Pivot Table prana1 Excel Discussion (Misc queries) 5 February 10th 07 03:08 AM
Prevent user changing pivot chart layout Jessica Excel Worksheet Functions 0 April 15th 06 12:24 AM
Changing the layout of a series of fields from Column to row maxmil Excel Discussion (Misc queries) 3 April 7th 06 04:12 PM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"