Consulting

Results 1 to 3 of 3

Thread: With...With end condition not working referencing a range

  1. #1

    With...With end condition not working referencing a range

    Hey guys, one question

    Does anyone found the same error than me with this condition? When i´m into one diferent activesheet from "Sammel-AEF", the code does not reference the rng2 var correctly and the routine fails. The countA does not understand that it has to look into the "Sammel-AEF" or the shtSammel columns and return it´s last used range...

    strange...or wrong...

    most probably, i´m wrong

    Option Explicit
    
    Sub dimw()
    Dim shtSammel As Worksheet
    Dim rng2 As range
    Dim last_col As Integer
    Set shtSammel = Worksheets("Sammel-AEF")
    With shtSammel
        If WorksheetFunction.CountA(cells) > 0 Then last_col = .cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
        
        Set rng2 = .range(.cells(1, 4), .cells(1, last_col))
    End With
    
    End Sub

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    If WorksheetFunction.CountA(.cells) >
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Quote Originally Posted by SamT View Post
    If WorksheetFunction.CountA(.cells) >
    Yep..SamT found it...thank you so much.

Posting Permissions

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