Consulting

Results 1 to 5 of 5

Thread: macro calling another macro

  1. #1

    macro calling another macro

    Hi all,

    please help me with the below two queries
    1)How to find programmatically, no of rows which is not blank. Can I useUsedrange.rows.count. If so do you have any examples.
    2) I have three macros. macro1,macro2,macro3
    Can anyone help me in writting another macro which will
    1)execute macro1
    2)Sort the data in sheet1 according to column H
    3)Remove all the rows which has column H blank
    4)execute macro2
    5)sort by column T largest to smallest
    6)remove all the rows which is having Column T below 14
    7)Sort by Column A add one more level and sort by column G
    8)execute macro 3

    Any help is appreciated

  2. #2
    VBAX Regular
    Joined
    Jun 2005
    Posts
    51
    Location
    For 1) try:

    Dim LastRow As Integer
    LastRow = ActiveSheet.UsedRange.Rows.Count

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    UsedRange.Rows.Count will count any embedded blank rows.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    You can have all of the above macros in one module and call them in sequence #2 To #8.
    [vba]
    Sub MyMac1()
    'End of MyMac1 Code
    Call MyMac2
    End Sub

    Sub MyMac2()
    'MyMac2 Code
    End Sub[/vba]
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    For 1) you could use Application.CountBlank, and probably various other methods.

    For the whole thing it might be interesting to know what the overall goal is.

    The steps you descrine aren't exactly identical but they do seem to follow some sort of pattern sort, filter/delete, sort...

    Perhaps it could all be done with one sub?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •