Consulting

Results 1 to 5 of 5

Thread: Range Problem

  1. #1

    Range Problem

    Hallo zusammen,

    bekomme immer die Fehlermeldung 424 (Objekt erforderlich) weis nicht warum :/
    Ziel ist es einen bereich auf Inhalt zu prüfen.

    Sub Start()
     
    dim Bereich as Range
     
    Set Bereich = Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 5)).Address <--- Hier kommt der Fehler. 
      
    If Bereich Is Nothing Then
          'TU DIES'                                
    Else
          'DU DAS'                                
    End If
    
    
    Besten Dank

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Set Bereich = Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 5)).Address <--- Hier kommt der Fehler. 
    
    Set Bereich = Range(ActiveCell.Offset(0, 1), ActiveCell.Offset(0, 5))
    "Set" is for Objects. "Address" is a String

    Maschinelle Übersetzung:
    "Set" ist für Objekte. "Adresse" ist ein String
    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
    Hey SamT,

    thanks for your answer, but i have this problem with your idea too, it comes the same ERROR 424.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Help File says..."[ActiveCell] Returns a Range object that represents the active cell in the active window (the window on top) or in the specified window. If the window isn't displaying a worksheet, this property fails. Read-only... If you don't specify an object qualifier, this property returns the active cell in the active window." (Emph by me)


    Try
    Sheets("SheetName").Activate
    Set Bereich = Application.ActiveCell.Offset(0, 1).Resize(1,4)
    Too bad you can't use "Selection." That's very easy
    Set Bereich = Selection.Offset(0, 1).Resize(1,4)
    Troubleshooting:
    MsgBox ActiveWindow.Caption 'Should be Workbook name
    MsgBox ActiveCell.Parent.Name 'Sheet  name
    MsgBox ActiveCell.Address
    Worst Case
    Dim ACAdd As String
    
    Sheets("SheetName").Activate
    ACAdd = ActiveCell.Address
    
    Set Bereich = Sheets("SheetName").Range(ACAdd).Offset(0, 1).Resize(1,4)
    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

  5. #5
    VBAX Newbie
    Joined
    Aug 2019
    Posts
    1
    Location
    I am also facing the same error 424 while implementing the code. Help me overcome my problem please
    Regards

Posting Permissions

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