#1   Report Post  
Member
 
Posts: 33
Default Combining macros

Hi all,

I'm looking to merge 2 macros in one so they both activate when i select a button. The macro code is as follows, the first needs to occur first.

MACRO 1:
Sub RemoveFormulasDeleteRows()
'
' RemoveFormulasDeleteRows Macro
' Macro recorded 19/01/2006 by Corus
'

'
Range("A14:R71").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("C16").Select
End Sub

MACRO 2
Function RowIsEmpty(n As Double) As Boolean
If Cells(n, 1).Value = "" And Cells(n, 1).End(xlToRight).Value = "" Then _
RowIsEmpty = True Else RowIsEmpty = False
End Function
Sub HideEmptyRows()
Dim tableEnd As Double
Dim m As Double

'tableEnd is set to the last row in the spreadsheet.
'work backwards from the last row upwards and hide the row if it is empty.

tableEnd = Range("a1").SpecialCells(xlCellTypeLastCell).Row
For m = tableEnd To 1 Step -1
If RowIsEmpty(m) Then Cells(m, 1).EntireRow.Hidden = True
Next m
End Sub

Any help with this would be appreciated.

Toms
  #2   Report Post  
Posted to microsoft.public.excel.misc
Stanley
 
Posts: n/a
Default Combining macros

Private Sub CommandButton1_Click()
Call RemoveFormulasDeleteRows
Call RowIsEmpty
End Sub

Just replace CommandButton1 with your button name. This will run them in the
order you see above.


"GarToms" wrote:


Hi all,

I'm looking to merge 2 macros in one so they both activate when i
select a button. The macro code is as follows, the first needs to
occur first.

MACRO 1:
Sub RemoveFormulasDeleteRows()
'
' RemoveFormulasDeleteRows Macro
' Macro recorded 19/01/2006 by Corus
'

'
Range("A14:R71").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("C16").Select
End Sub

MACRO 2
Function RowIsEmpty(n As Double) As Boolean
If Cells(n, 1).Value = "" And Cells(n, 1).End(xlToRight).Value = ""
Then _
RowIsEmpty = True Else RowIsEmpty = False
End Function
Sub HideEmptyRows()
Dim tableEnd As Double
Dim m As Double

'tableEnd is set to the last row in the spreadsheet.
'work backwards from the last row upwards and hide the row if it is
empty.

tableEnd = Range("a1").SpecialCells(xlCellTypeLastCell).Row
For m = tableEnd To 1 Step -1
If RowIsEmpty(m) Then Cells(m, 1).EntireRow.Hidden = True
Next m
End Sub

Any help with this would be appreciated.

Toms


--
GarToms

  #3   Report Post  
Member
 
Posts: 33
Default

I'm trying to make a macro out of this but it doesn't appear in the macro list when i put it in vb. Does anyone know how i can use this code?

Private Sub Generate()
Call PasteBus
Call HideEmptyRows
Call No Loop
End Sub


Quote:
Originally Posted by Stanley
Private Sub CommandButton1_Click()
Call RemoveFormulasDeleteRows
Call RowIsEmpty
End Sub

Just replace CommandButton1 with your button name. This will run them in the
order you see above.


"GarToms" wrote:


Hi all,

I'm looking to merge 2 macros in one so they both activate when i
select a button. The macro code is as follows, the first needs to
occur first.

MACRO 1:
Sub RemoveFormulasDeleteRows()
'
' RemoveFormulasDeleteRows Macro
' Macro recorded 19/01/2006 by Corus
'

'
Range("A14:R71").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("C16").Select
End Sub

MACRO 2
Function RowIsEmpty(n As Double) As Boolean
If Cells(n, 1).Value = "" And Cells(n, 1).End(xlToRight).Value = ""
Then _
RowIsEmpty = True Else RowIsEmpty = False
End Function
Sub HideEmptyRows()
Dim tableEnd As Double
Dim m As Double

'tableEnd is set to the last row in the spreadsheet.
'work backwards from the last row upwards and hide the row if it is
empty.

tableEnd = Range("a1").SpecialCells(xlCellTypeLastCell).Row
For m = tableEnd To 1 Step -1
If RowIsEmpty(m) Then Cells(m, 1).EntireRow.Hidden = True
Next m
End Sub

Any help with this would be appreciated.

Toms


--
GarToms
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
Excel crashes while opening excel file imbeddied with macros ct2147 Excel Discussion (Misc queries) 0 December 30th 05 09:05 PM
VBA Switching Between Macros Jeff Excel Discussion (Misc queries) 4 November 5th 05 12:45 AM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM
The available macros list in XL; how to suppress filename from showing KR Excel Discussion (Misc queries) 1 January 10th 05 07:20 PM


All times are GMT +1. The time now is 05:57 AM.

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"