Consulting

Results 1 to 4 of 4

Thread: Find out row and column range

  1. #1
    VBAX Newbie
    Joined
    Aug 2017
    Posts
    4
    Location

    Find out row and column range

    Hi at all,

    I got a lil problem.
    Can somebody explain to me whats the differend between ..

    AnZ = Cells(Rows.Count, 1).End(xlUp).Row ' shows a MsgBox with "3" cause Mappe1 : Hello (1,1) Hello (1,2) Hello(3,1)
    and
    Anz = UsedRange.Rows.Count ' aint work

    By the way , why would this not work...
    AnZ = Mappe1.Cells(Rows.Count, 1).End(xlUp).Row

    ' Mappe1 is declared Dim Mappe1 As Workbook
    Set Mappe1 = ThisWorkbook


    Im new in VBA , excuse my english im from Germany

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    'Mappe1 is I believe the VB code name for, in my terms, Sheet1. It can be used to refer to the sheet as shown below. You would not Dim Mappe1

    To refer to it you could use
    Dim ws as worksheet

    Set ws = Mappe1
    or
    Set ws = Sheets("Mappe1")

    If you qualify Cells with ws, Mappe1 or other, then Anz will return the value relevant to that sheet, rather than the Active Sheet.


    Sub Test1()
    'This will return Anz for the Active Sheet
    Anz = Cells(Rows.Count, 1).End(xlUp).Row
    MsgBox Anz
    End Sub
    
    
    Sub Test2()
    'Mappe1 is I believe the VB code name for, in my terms, Sheet1
    Anz = Mappe1.UsedRange.Rows.Count
    MsgBox Anz
    'or
    Anz = Sheets("Mappe1").UsedRange.Rows.Count
    MsgBox Anz
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Newbie
    Joined
    Aug 2017
    Posts
    4
    Location
    Hi thx for the Answer, Mappe1 is Workbook in my structure

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks for that. What are worksheets called?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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