Consulting

Results 1 to 3 of 3

Thread: Solved: Calling a Function and Resize

  1. #1
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location

    Solved: Calling a Function and Resize

    Is it possible to call a function to get the desired number to use in a resize statement? For example, there is a function called getRows that defines the number of current data rows exist. I tried the following but it did not work.

    [VBA]
    Selection.Resize(getRows).Select
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    That should work.

    This worked for me

    [vba]

    Sub ResizeIt()
    Selection.Resize(getRows).Select
    End Sub

    Function getRows()
    getRows = 5
    End Function
    [/vba]
    ____________________________________________
    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

  3. #3
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Your response caused me to see what I think might have been my problem. getRows was a subroutine rather than a function. After seeing your example, I changed it to a function and it works fine now. Thanks.

Posting Permissions

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