Consulting

Results 1 to 4 of 4

Thread: Solved: Count Total Columns used in Sheet

  1. #1
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location

    Solved: Count Total Columns used in Sheet

    Hi All,

    Pl help me in getting total columns used in my worksheet through VBA code.
    i got how to count total used rows but not getting for total column used.

    the code for total rows used in sheet is

    [VBA] testrow = activesheet.Cells(Rows.Count, 1).End(xlUp).Row[/VBA]

    pl tell me the code in same way for getting total column used in sheet

    awaiting for your reply.

  2. #2
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    [VBA]ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column[/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  3. #3
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    thanks johnske
    actually i was using xlleft instead of xltoleft & hence continuously getting error.


    thanks for such quick reply.

  4. #4
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Quote Originally Posted by anandbohra
    ... i was using xlleft instead of xltoleft & hence continuously getting error...
    That's a very common mistake
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

Posting Permissions

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