Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Putting macros together

How do you guys put or run two macros together in one macro. I have to
separate macros that i want to run one after each other in one macro.


Sub DeleteColumns()
Dim i As Integer

For i = 256 To 1 Step -1
If Cells(1, i).Text = "Rank" Or _
Cells(1, i).Text = "Housing units" Or _
Cells(1, i).Text = "Occupied Housing Units" Or _
Cells(1, i).Text = "Vacant Housing Units" Then
Cells(1, i).EntireColumn.Delete
End If
Next i
End Sub

----------------------and

Sub DeleteColumns()
Dim i As Integer

For i = 256 To 1 Step -1
If Cells(2, i).Text = "Subtotal of High" Or _
Cells(2, i).Text = "Subtotal of Extremely High" Or _
Cells(2, i).Text = "Subtotal of Average" Or _
Cells(2, i).Text = "Subtotal of Below Average" Or _
Cells(2, i).Text = "Subtotal of Above Average" Or _
Cells(2, i).Text = "Grand Total" Then
Cells(2, i).EntireRow.Delete
End If
Next i
End Sub

--
Message posted via http://www.officekb.com

  #3   Report Post  
Posted to microsoft.public.excel.misc
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Putting macros together

Hi,

First you have to change the name of your second macro to be different than
the name of the first macro.
For example Sub DeleteColumns() and Sub DeleteColumns_2()
Then copy this code:

Sub Run_both_macros()
' Macro recorded 7/24/2007 by Tim
DeleteColumns
DeleteColumns_2
End Sub

Go to your workbookhit Alt+F11Double click a module and paste my
codeclose VB EditorAlt+F8 and run macro: Run_both_macros

Regards,

Tim


"saman110 via OfficeKB.com" wrote:

How do you guys put or run two macros together in one macro. I have to
separate macros that i want to run one after each other in one macro.


Sub DeleteColumns()
Dim i As Integer

For i = 256 To 1 Step -1
If Cells(1, i).Text = "Rank" Or _
Cells(1, i).Text = "Housing units" Or _
Cells(1, i).Text = "Occupied Housing Units" Or _
Cells(1, i).Text = "Vacant Housing Units" Then
Cells(1, i).EntireColumn.Delete
End If
Next i
End Sub

----------------------and

Sub DeleteColumns()
Dim i As Integer

For i = 256 To 1 Step -1
If Cells(2, i).Text = "Subtotal of High" Or _
Cells(2, i).Text = "Subtotal of Extremely High" Or _
Cells(2, i).Text = "Subtotal of Average" Or _
Cells(2, i).Text = "Subtotal of Below Average" Or _
Cells(2, i).Text = "Subtotal of Above Average" Or _
Cells(2, i).Text = "Grand Total" Then
Cells(2, i).EntireRow.Delete
End If
Next i
End Sub

--
Message posted via http://www.officekb.com


  #4   Report Post  
Posted to microsoft.public.excel.misc
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Putting macros together

When in VB Editor instead double click a module got to InsertNew Module and
then Paste

Tim





  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Putting macros together

Thank you for your response.

What if you have 3 macros to run?

Tim wrote:
Hi,

First you have to change the name of your second macro to be different than
the name of the first macro.
For example Sub DeleteColumns() and Sub DeleteColumns_2()
Then copy this code:

Sub Run_both_macros()
' Macro recorded 7/24/2007 by Tim
DeleteColumns
DeleteColumns_2
End Sub

Go to your workbookhit Alt+F11Double click a module and paste my
codeclose VB EditorAlt+F8 and run macro: Run_both_macros

Regards,

Tim

How do you guys put or run two macros together in one macro. I have to
separate macros that i want to run one after each other in one macro.

[quoted text clipped - 28 lines]
Next i
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200707/1



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Putting macros together

Nevermind I got it.

thx
saman110 wrote:
Thank you for your response.

What if you have 3 macros to run?

Hi,

[quoted text clipped - 21 lines]
Next i
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200707/1

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
putting symbols Jammal Excel Discussion (Misc queries) 2 July 7th 06 04:56 PM
Putting many columns into one jezzica85 Excel Discussion (Misc queries) 2 February 26th 06 01:30 PM
Putting macros on a toolbar Dudley Excel Discussion (Misc queries) 2 February 24th 06 01:21 PM
putting jpg files into csv? Oldguard Excel Discussion (Misc queries) 1 February 14th 06 02:17 AM
putting in a sum finction Hru48 Excel Discussion (Misc queries) 5 January 6th 06 12:42 PM


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