ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Basic Question on Subs (https://www.excelbanter.com/excel-worksheet-functions/93265-basic-question-subs.html)

JOUIOUI

Basic Question on Subs
 
This is the most basic question I'm sure but how can I link numerous sub
statements into one macro?

Toppers

Basic Question on Subs
 
Sub MyMacros()

Call macro1
Call macro2
etc

End Sub

"Call" can be omitted from the above statements except if parameters are
passed to the routine.


HTH



"JOUIOUI" wrote:

This is the most basic question I'm sure but how can I link numerous sub
statements into one macro?


Dave Peterson

Basic Question on Subs
 
Like this???

Sub MainProgramNameHere()
call Prog1
call Prog2
'do some stuff locally??
call prog3
end sub



JOUIOUI wrote:

This is the most basic question I'm sure but how can I link numerous sub
statements into one macro?


--

Dave Peterson

SITCFanTN

Basic Question on Subs
 
Hi Dave,

Thanks for your help. I was hoping you could help me with this. My Sheet 1
is "All Records", I"m adding 6 new sheets which works great, but then the Add
REcords is not working. I'm trying to copy any rows with "4-$" in column A
and "GESA CC" in column B from the "All Records" Sheet to the "GESA CC"
Sheet. ANy ideas?

Sub AllRecordsSortMacros()

Call AddSheets
Call AddRecords


End Sub
Sub AddSheets()

Dim NewSheets As Variant
Dim i As Long

NewSheets = Array("Confirm", "GESV CC", "GESA CC", "GESA CK", "All
Matches", "All Non Matches")
For i = UBound(NewSheets) To LBound(NewSheets) Step -1
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = NewSheets(i)
Next i

End Sub

Sub CopyData()
Dim rng As Range, cell As Range
Dim i As Long, sh As Worksheet
With Worksheets("All Matches")
Set rng = .Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
End With
i = 1
Set sh = Worksheets("GESA CC")
For Each cell In rng
If UCase(Trim(cell.Value)) = "4-$" And _
UCase(Trim(cell.Offset(0, 1).Value)) = "Gesa CC" Then
cell.EntireRow.Copy sh.Cells(i, 1)
i = i + 1
End If
Next
End Sub

"Dave Peterson" wrote:

Like this???

Sub MainProgramNameHere()
call Prog1
call Prog2
'do some stuff locally??
call prog3
end sub



JOUIOUI wrote:

This is the most basic question I'm sure but how can I link numerous sub
statements into one macro?


--

Dave Peterson


Dave Peterson

Basic Question on Subs
 
Without too much looking...

If UCase(Trim(cell.Offset(0, 1).Value)) = "Gesa CC" Then

You're comparing something that upper case (you used uCase()) with "Gesa CC".
Well, there aren't any uppercase letters that match "esa", so there will never
be a match.

You could use:
If UCase(Trim(cell.Offset(0, 1).Value)) = "GESA CC" Then
or if you're really lazy:
If UCase(Trim(cell.Offset(0, 1).Value)) = ucase("Gesa CC") Then



SITCFanTN wrote:

Hi Dave,

Thanks for your help. I was hoping you could help me with this. My Sheet 1
is "All Records", I"m adding 6 new sheets which works great, but then the Add
REcords is not working. I'm trying to copy any rows with "4-$" in column A
and "GESA CC" in column B from the "All Records" Sheet to the "GESA CC"
Sheet. ANy ideas?

Sub AllRecordsSortMacros()

Call AddSheets
Call AddRecords

End Sub
Sub AddSheets()

Dim NewSheets As Variant
Dim i As Long

NewSheets = Array("Confirm", "GESV CC", "GESA CC", "GESA CK", "All
Matches", "All Non Matches")
For i = UBound(NewSheets) To LBound(NewSheets) Step -1
Sheets.Add after:=Sheets(1)
ActiveSheet.Name = NewSheets(i)
Next i

End Sub

Sub CopyData()
Dim rng As Range, cell As Range
Dim i As Long, sh As Worksheet
With Worksheets("All Matches")
Set rng = .Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
End With
i = 1
Set sh = Worksheets("GESA CC")
For Each cell In rng
If UCase(Trim(cell.Value)) = "4-$" And _
UCase(Trim(cell.Offset(0, 1).Value)) = "Gesa CC" Then
cell.EntireRow.Copy sh.Cells(i, 1)
i = i + 1
End If
Next
End Sub

"Dave Peterson" wrote:

Like this???

Sub MainProgramNameHere()
call Prog1
call Prog2
'do some stuff locally??
call prog3
end sub



JOUIOUI wrote:

This is the most basic question I'm sure but how can I link numerous sub
statements into one macro?


--

Dave Peterson


--

Dave Peterson


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com