Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default I need a Macro?

Hi,

I have a spreadsheet were I have list of accounts and they are catergorized
by location in the same column. for example in Column B

1001 (Account)
1002 (Account)
1003 (Account)
1004 (Account)
1005 (Account)
J101(Location)
1001 (Account)
1002 (Account)
1003 (Account)
1005 (Account)
J102 (Location)

so it will list the accounts and then the last item will be the location.
What I want to do is have the location in column a right next to the account.
Doea anyone have a macro that can go down the list put the location in front
of the account?

Thanks
Mascot
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default I need a Macro?

Can you use a formula?
In cell A1 type: =MID(B1,FIND(" ",B1,1),255)
Or if the account # is always 4 numbers/letters
In cell A1 type: =MID(B1,5,255)
then just drag down the formula as far as needed.
Next use copy....pastevalue for column A:A.
Also the "trim" function will delete any unwanted spaces

--
Mike Q.


"Mascot" wrote:

Hi,

I have a spreadsheet were I have list of accounts and they are catergorized
by location in the same column. for example in Column B

1001 (Account)
1002 (Account)
1003 (Account)
1004 (Account)
1005 (Account)
J101(Location)
1001 (Account)
1002 (Account)
1003 (Account)
1005 (Account)
J102 (Location)

so it will list the accounts and then the last item will be the location.
What I want to do is have the location in column a right next to the account.
Doea anyone have a macro that can go down the list put the location in front
of the account?

Thanks
Mascot

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default I need a Macro?

Assumes account numbers are numeric and locations on alphanumeric as your
example shows.

Sub Add Data()
dim lastrow as Long
Dim i as Long, loc as String

Columns(1).ClearContents
lastrow = cells(rows.count,2).End(xlup).row

for i = lastrow to 1 step -1
if isnumeric(cells(i,2)) then
cells(i,1) = Loc
else
loc = cells(i,2)
end if
Next

' optional to delete the location rows
On Error Resume Next
Columns(1).SpecialCells(xlbanks).EntireRow.Delete
On Error goto 0
End Sub

Test it on a copy of your data.

--
Regards,
Tom Ogilvy


"Mascot" wrote:

Hi,

I have a spreadsheet were I have list of accounts and they are catergorized
by location in the same column. for example in Column B

1001 (Account)
1002 (Account)
1003 (Account)
1004 (Account)
1005 (Account)
J101(Location)
1001 (Account)
1002 (Account)
1003 (Account)
1005 (Account)
J102 (Location)

so it will list the accounts and then the last item will be the location.
What I want to do is have the location in column a right next to the account.
Doea anyone have a macro that can go down the list put the location in front
of the account?

Thanks
Mascot

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default I need a Macro?

Hi Tom,

Thanks for getting back to me. I can't seem to get it to work. I guess I
left something out in my explanation. This is a better example of how column
B looks. Let me know if you can help.

Thanks
Mascot

s1001 (Account)
s1002 (Account)
s1003 (Account)
s1004 (Account)
s1005 (Account)
*J101(Location)
s1001 (Account)
s1002 (Account)
s1003 (Account)
s1005 (Account)
*J102 (Location)
s1001 (Account)
s1002 (Account)
s1003 (Account)
s1005 (Account
*J103 (Location)

etc.


"Tom Ogilvy" wrote:

Assumes account numbers are numeric and locations on alphanumeric as your
example shows.

Sub Add Data()
dim lastrow as Long
Dim i as Long, loc as String

Columns(1).ClearContents
lastrow = cells(rows.count,2).End(xlup).row

for i = lastrow to 1 step -1
if isnumeric(cells(i,2)) then
cells(i,1) = Loc
else
loc = cells(i,2)
end if
Next

' optional to delete the location rows
On Error Resume Next
Columns(1).SpecialCells(xlbanks).EntireRow.Delete
On Error goto 0
End Sub

Test it on a copy of your data.

--
Regards,
Tom Ogilvy


"Mascot" wrote:

Hi,

I have a spreadsheet were I have list of accounts and they are catergorized
by location in the same column. for example in Column B

1001 (Account)
1002 (Account)
1003 (Account)
1004 (Account)
1005 (Account)
J101(Location)
1001 (Account)
1002 (Account)
1003 (Account)
1005 (Account)
J102 (Location)

so it will list the accounts and then the last item will be the location.
What I want to do is have the location in column a right next to the account.
Doea anyone have a macro that can go down the list put the location in front
of the account?

Thanks
Mascot

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default I need a Macro?

Account numbers start with "s"?

Sub Add Data()
dim lastrow as Long
Dim i as Long, loc as String

Columns(1).ClearContents
lastrow = cells(rows.count,2).End(xlup).row

for i = lastrow to 1 step -1
if lcase(Left(cells(i,2),1)) = "s" then
cells(i,1) = Loc
else
loc = cells(i,2)
end if
Next

' optional to delete the location rows
On Error Resume Next
Columns(1).SpecialCells(xlbanks).EntireRow.Delete
On Error goto 0
End Sub


--
Regards,
Tom Ogilvy


"Mascot" wrote in message
...
Hi Tom,

Thanks for getting back to me. I can't seem to get it to work. I guess I
left something out in my explanation. This is a better example of how
column
B looks. Let me know if you can help.

Thanks
Mascot

s1001 (Account)
s1002 (Account)
s1003 (Account)
s1004 (Account)
s1005 (Account)
*J101(Location)
s1001 (Account)
s1002 (Account)
s1003 (Account)
s1005 (Account)
*J102 (Location)
s1001 (Account)
s1002 (Account)
s1003 (Account)
s1005 (Account
*J103 (Location)

etc.


"Tom Ogilvy" wrote:

Assumes account numbers are numeric and locations on alphanumeric as your
example shows.

Sub Add Data()
dim lastrow as Long
Dim i as Long, loc as String

Columns(1).ClearContents
lastrow = cells(rows.count,2).End(xlup).row

for i = lastrow to 1 step -1
if isnumeric(cells(i,2)) then
cells(i,1) = Loc
else
loc = cells(i,2)
end if
Next

' optional to delete the location rows
On Error Resume Next
Columns(1).SpecialCells(xlbanks).EntireRow.Delete
On Error goto 0
End Sub

Test it on a copy of your data.

--
Regards,
Tom Ogilvy


"Mascot" wrote:

Hi,

I have a spreadsheet were I have list of accounts and they are
catergorized
by location in the same column. for example in Column B

1001 (Account)
1002 (Account)
1003 (Account)
1004 (Account)
1005 (Account)
J101(Location)
1001 (Account)
1002 (Account)
1003 (Account)
1005 (Account)
J102 (Location)

so it will list the accounts and then the last item will be the
location.
What I want to do is have the location in column a right next to the
account.
Doea anyone have a macro that can go down the list put the location in
front
of the account?

Thanks
Mascot



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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 12:11 PM.

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

About Us

"It's about Microsoft Excel"