Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 27
Default Need to create Excel 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.misc
external usenet poster
 
Posts: 1
Default Need to create Excel Macro?


Assuming all your data has a space why don't you just use a formula like
the one below ??


=RIGHT(E1,LEN(E1)-FIND(" ",E1,1))&" "&LEFT(E1,FIND(" ",E1,1)-1)


--
VBA Noob
------------------------------------------------------------------------
VBA Noob's Profile: http://www.excelforum.com/member.php...o&userid=33833
View this thread: http://www.excelforum.com/showthread...hreadid=564408

  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Need to create Excel Macro?

Assuming your locations all begin w/a letter (so it is not possible they
could be interpreted as numbers). After putting the location in the column
to the left of your data, this macro also deletes the rows in your data that
had the locations, so be sure to backup your data before trying. Also, you
have to select the data you want the macro to run on beforehand.

Sub test()
Dim rngCell As Range
Dim rngDelete As Range
Dim rngTemp As Range

If Selection.Columns.Count 1 Then End

For Each rngCell In Selection.Cells
If Not IsNumeric(rngCell.Value) Then
If rngTemp Is Nothing Then
rngCell.Copy Range(Selection.Cells(1)(1, 0), rngCell(0, 0))
Else: rngCell.Copy Range(rngTemp(2, 0), rngCell(0, 0))
End If
Set rngTemp = rngCell
If rngDelete Is Nothing Then
Set rngDelete = rngCell
Else: Set rngDelete = Union(rngCell, rngDelete)
End If
End If
Next rngCell

If Not rngDelete Is Nothing Then _
rngDelete.EntireRow.Delete

End Sub

"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.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Need to create Excel Macro?

Another way you could do it is to use formulae

Enter in cell A1:

=IF(ISTEXT(B1),"",IF(ISTEXT(B2),B2,A2))
and copy down. If you want the data hardcoded, select column A and copy,
then Edit/Paste Special-values. After this, if you want to get rid of the
locations in your data in column B, use Autofilter to filter for blanks in
column A, delete the filtered rows, then turn off Autofilter.



"JMB" wrote:

Assuming your locations all begin w/a letter (so it is not possible they
could be interpreted as numbers). After putting the location in the column
to the left of your data, this macro also deletes the rows in your data that
had the locations, so be sure to backup your data before trying. Also, you
have to select the data you want the macro to run on beforehand.

Sub test()
Dim rngCell As Range
Dim rngDelete As Range
Dim rngTemp As Range

If Selection.Columns.Count 1 Then End

For Each rngCell In Selection.Cells
If Not IsNumeric(rngCell.Value) Then
If rngTemp Is Nothing Then
rngCell.Copy Range(Selection.Cells(1)(1, 0), rngCell(0, 0))
Else: rngCell.Copy Range(rngTemp(2, 0), rngCell(0, 0))
End If
Set rngTemp = rngCell
If rngDelete Is Nothing Then
Set rngDelete = rngCell
Else: Set rngDelete = Union(rngCell, rngDelete)
End If
End If
Next rngCell

If Not rngDelete Is Nothing Then _
rngDelete.EntireRow.Delete

End Sub

"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
Importing EXCEL Spreadsheets into ACCESS -- Macro or VBA? Excel Discussion (Misc queries) 0 July 12th 06 10:08 PM
excel - create a macro to use cell text as part of a file name bossman tv New Users to Excel 1 June 27th 06 10:38 PM
Macro problem in Excel pd Excel Discussion (Misc queries) 2 March 14th 06 05:49 AM
Create an Excel file using a macro Cillian Excel Discussion (Misc queries) 0 January 9th 06 06:32 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM


All times are GMT +1. The time now is 09:27 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"