Re: $$Excel-Macros$$ Create macro to reformat spreadsheet for importing
Vasant, Thanks for the help. I can play around with this macro and do everything I need. Also do you know can you run a macro from a different spreadsheet? I'm going to be getting a spreadsheet every few weeks and will need to run this macro against the spreadsheet. I don't want the users to import the macro every time they need to export the data. Or do you have any suggestions? Thanks again for the help. On Jul 30, 12:18 pm, Vasant wrote: > HI, > > Hope this helps > > pls run the macro "ALign" in the attached file. > > Data in "Sheet1" is aligned in "Sheet2". I hv copied the code for your > convenience. > > *Sub Align() > Dim Wksht As Worksheet, NWksht As Worksheet > Set Wksht = ThisWorkbook.Worksheets("Sheet1") > Set NWksht = ThisWorkbook.Worksheets("Sheet2") > Lrow = Wksht.Cells.SpecialCells(xlCellTypeLastCell).Row > Cntr = 1 > For x = 1 To Lrow > If Len(Wksht.Cells(x, 1)) = 4 Then > NWksht.Cells(Cntr, 1) = Wksht.Cells(x, 1) > NWksht.Cells(Cntr, 2) = Wksht.Cells(x + 2, 1) > NWksht.Cells(Cntr, 2) = Wksht.Cells(x + 3, 1) > Cntr = Cntr + 1 > End If > Next x > End Sub* > > Regards > Vasant > > > > On Fri, Jul 30, 2010 at 7:56 PM, Ecovindaloo wrote: > > I need to create macro to reformat spreadsheet for importing into > > Access. As usual the spreadsheet is not formatted properly. > > > Here is a piece of the spreadsheet: > > 3196 > > > 28320221EBLADENST 39294812 > > 275813701MABLELANE 40189085 > > > 3200 > > > 601771294ANGELINEDRIVE 40240796 > > 60136321JOHNMBOORDR 39278689 > > > 3207 > > > 271062990CARRIAGEDRRAMSGAT 39345882 > > 271065981OLDPLANKRD 39456725 > > > What I need to do is create a macro to add a column and then take the > > ID Number (i.e. 3169) and put it in those rows below. Then delete the > > row with the ID Number and blank rows. Is there any easy way to do > > this in a macro? > > > Thanks in advance for the help. > > > -- > > > -- > > Some important links for excel users: > > 1. Follow us on TWITTER for tips tricks and links : > >http://twitter.com/exceldailytip > > 2. Join our LinkedIN group @http://www.linkedin.com/groups?gid=1871310 > > 3. Excel tutorials athttp://www.excel-macros.blogspot.com > > 4. Learn VBA Macros athttp://www.quickvba.blogspot.com > > 5. Excel Tips and Tricks athttp://exceldailytip.blogspot.com > > > To post to this group, send email to excel-macros@googlegroups.com > > > <><><><><><><><><><><><><><><><><><><><><><> > > HELP US GROW !! > > > We reach over 7000 subscribers worldwide and receive many nice notes about > > the learning and support from the group.Let friends and co-workers know they > > can subscribe to group at > >http://groups.google.com/group/excel-macros/subscribe > > -- > Regards > > Vasant > > Book1.xls > 45KViewDownload -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 7000 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe
Re: $$Excel-Macros$$ Create macro to reformat spreadsheet for importing
HI, Hope this helps pls run the macro "ALign" in the attached file. Data in "Sheet1" is aligned in "Sheet2". I hv copied the code for your convenience. *Sub Align() Dim Wksht As Worksheet, NWksht As Worksheet Set Wksht = ThisWorkbook.Worksheets("Sheet1") Set NWksht = ThisWorkbook.Worksheets("Sheet2") Lrow = Wksht.Cells.SpecialCells(xlCellTypeLastCell).Row Cntr = 1 For x = 1 To Lrow If Len(Wksht.Cells(x, 1)) = 4 Then NWksht.Cells(Cntr, 1) = Wksht.Cells(x, 1) NWksht.Cells(Cntr, 2) = Wksht.Cells(x + 2, 1) NWksht.Cells(Cntr, 2) = Wksht.Cells(x + 3, 1) Cntr = Cntr + 1 End If Next x End Sub* Regards Vasant On Fri, Jul 30, 2010 at 7:56 PM, Ecovindaloo wrote: > I need to create macro to reformat spreadsheet for importing into > Access. As usual the spreadsheet is not formatted properly. > > > Here is a piece of the spreadsheet: > 3196 > > 28320221EBLADENST 39294812 > 275813701MABLELANE 40189085 > > 3200 > > 601771294ANGELINEDRIVE 40240796 > 60136321JOHNMBOORDR 39278689 > > 3207 > > 271062990CARRIAGEDRRAMSGAT 39345882 > 271065981OLDPLANKRD 39456725 > > What I need to do is create a macro to add a column and then take the > ID Number (i.e. 3169) and put it in those rows below. Then delete the > row with the ID Number and blank rows. Is there any easy way to do > this in a macro? > > Thanks in advance for the help. > > -- > > -- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > HELP US GROW !! > > We reach over 7000 subscribers worldwide and receive many nice notes about > the learning and support from the group.Let friends and co-workers know they > can subscribe to group at > http://groups.google.com/group/excel-macros/subscribe > -- Regards Vasant -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 7000 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe Book1.xls Description: MS-Excel spreadsheet
$$Excel-Macros$$ Create macro to reformat spreadsheet for importing
I need to create macro to reformat spreadsheet for importing into Access. As usual the spreadsheet is not formatted properly. Here is a piece of the spreadsheet: 3196 28320221EBLADENST 39294812 275813701MABLELANE 40189085 3200 601771294ANGELINEDRIVE 40240796 60136321JOHNMBOORDR 39278689 3207 271062990CARRIAGEDRRAMSGAT 39345882 271065981OLDPLANKRD 39456725 What I need to do is create a macro to add a column and then take the ID Number (i.e. 3169) and put it in those rows below. Then delete the row with the ID Number and blank rows. Is there any easy way to do this in a macro? Thanks in advance for the help. -- -- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 7000 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe