Consulting

Results 1 to 2 of 2

Thread: Autofill a resize range

  1. #1

    Autofill a resize range

    i'm working on a macro, and i use `resize` to select a range. Wich range i use in `autofill`. the original adress of `strPlageNumSemaines` is `AB5`. I don't know why it's still has `AB5` address even after the resize. Here is my code:



    Dim strDernierJourDuMois As String
         Dim strPlageNumSemaines As String
         count = 0
    
    
        strPlageNumSemaines = Range(strDernierJourDuMois).Offset(0, 1).Address
        strPlageNumSemaines = Range(strPlageNumSemaines).Resize(1, count)
     
     
        If dbNbSemaines = 4 Then
         count = 4
        ElseIf dbNbSemaines = 5 Then
         count = 5
        End If
      
        Range("E5:AE5").Find(dtDernierJourDuMois, Range("E5")).Offset(0, 1).Select
        Selection.AutoFill Destination:=Range(strPlageNumSemaines),Type:=xlFillDefault

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this

    Dim strDernierJourDuMois As String
    Dim strPlageNumSemaines As Range
    
        Count = 0
     
        Set strPlageNumSemaines = Range(strDernierJourDuMois).Offset(0, 1).Resize(1, Count)
         
        If dbNbSemaines = 4 Then
            Count = 4
        ElseIf dbNbSemaines = 5 Then
            Count = 5
        End If
         
        Range("E5:AE5").Find(dtDernierJourDuMois, Range("E5")).Offset(0, 1).Select
        Selection.AutoFill Destination:=strPlageNumSemaines, Type:=xlFillDefault
    ____________________________________________
    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

Tags for this Thread

Posting Permissions

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