Results 1 to 3 of 3

Thread: Start Loop in "A2"

  1. #1
    Board Regular
    Join Date
    May 2008
    Location
    Austria
    Posts
    1,083
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Start Loop in "A2"

    Hi guys,

    I got this code from a a gast user of a different forum. "Volker"

    I did modify it a little but seam not be able to get the loop started at "A2" rather then "A1".

    Code:
    Sub FillDaysOfMonth()
        Dim datStart As Date
        Dim datEnd As Date
        Dim d As Date
        
        Columns(1).ClearContents
        Range("A1").Value = "Datum"
        
        datStart = DateSerial(Year(Cells(1, 5)), Month(Cells(1, 5)), 1)
        datEnd = DateSerial(Year(datStart), Month(datStart) + 1, 1) - 1
        
        For d = datStart To datEnd
            Cells(Day(d), 1) = d
        Next d
    End Sub
    does anyone know how I need to change this code above to make that work?

    Many thanks"
    Silentwolf



    I use MS Office 2010 and Windows 7

  2. #2
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    35,232
    Post Thanks / Like
    Mentioned
    92 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Start Loop in "A2"

    Quote Originally Posted by silentwolf View Post
    Hi guys,

    I got this code from a a gast user of a different forum. "Volker"

    I did modify it a little but seam not be able to get the loop started at "A2" rather then "A1".

    Code:
    Sub FillDaysOfMonth()
        Dim datStart As Date
        Dim datEnd As Date
        Dim d As Date
        
        Columns(1).ClearContents
        Range("A1").Value = "Datum"
        
        datStart = DateSerial(Year(Cells(1, 5)), Month(Cells(1, 5)), 1)
        datEnd = DateSerial(Year(datStart), Month(datStart) + 1, 1) - 1
        
        For d = datStart To datEnd
            Cells(Day(d) + 1, 1) = d
        Next d
    End Sub
    does anyone know how I need to change this code above to make that work?
    Maybe adding what I show in red will do it.
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  3. #3
    Board Regular
    Join Date
    May 2008
    Location
    Austria
    Posts
    1,083
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Start Loop in "A2"

    Hi Rick,

    yes it works fine!
    I tried with Cells(Day(d)1 ,1)=d
    before...

    hmm never stop learning
    Silentwolf



    I use MS Office 2010 and Windows 7

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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