+ Reply to Thread
Results 1 to 5 of 5

Thread: Excel Macros

  1. #1
    Registered User
    Join Date
    10-20-2005
    Posts
    10

    Excel Macros

    I am trying to design a macro to work with a database I made in excel. I have a lot of questions since I have never made a macro before. But I'll just start with a simple question. I want to run a macro that will input the current date in cell a1, then when I run the macro the next day, I want to input the current date in cell a2. How do I set up a macro to do that? I tried setting up a counter but I don't know how to say something like Range(a1 + 1) = Now. So it selects the next cell down everytime I run it. Thanks for the help in advance.

    Jason

  2. #2
    Bob Phillips
    Guest

    Re: Excel Macros

    Dim iLastRow as Long

    iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Tyhen
    'do nothing
    Else
    iLastRow = iLastRow + 1
    Cells(iNextRow,"A").Value = Format(Date,"dd mmm yyyy")
    End If

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "cappuccine" <cappuccine.1xxt2p_1131048762.9439@excelforum-nospam.com> wrote
    in message news:cappuccine.1xxt2p_1131048762.9439@excelforum-nospam.com...
    >
    > I am trying to design a macro to work with a database I made in excel. I
    > have a lot of questions since I have never made a macro before. But I'll
    > just start with a simple question. I want to run a macro that will input
    > the current date in cell a1, then when I run the macro the next day, I
    > want to input the current date in cell a2. How do I set up a macro to
    > do that? I tried setting up a counter but I don't know how to say
    > something like Range(a1 + 1) = Now. So it selects the next cell down
    > everytime I run it. Thanks for the help in advance.
    >
    > Jason
    >
    >
    > --
    > cappuccine
    > ------------------------------------------------------------------------
    > cappuccine's Profile:

    http://www.excelforum.com/member.php...o&userid=28242
    > View this thread: http://www.excelforum.com/showthread...hreadid=482005
    >




  3. #3
    Roger Govier
    Guest

    Re: Excel Macros

    A couple of typos.
    What Bob meant to type was

    Dim iLastRow as Long

    iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Then
    'do nothing
    Else
    iLastRow = iLastRow + 1
    Cells(iLastRow,"A").Value = Format(Date,"dd mmm yyyy")
    End If


    Regards

    Roger Govier


    Bob Phillips wrote:
    > Dim iLastRow as Long
    >
    > iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    > If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Tyhen
    > 'do nothing
    > Else
    > iLastRow = iLastRow + 1
    > Cells(iNextRow,"A").Value = Format(Date,"dd mmm yyyy")
    > End If
    >


  4. #4
    Bob Phillips
    Guest

    Re: Excel Macros

    Thanks Roger, but there is a also a logic error. Should be

    Dim iLastRow as Long

    iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Then
    'do nothing
    Else
    iLastRow = iLastRow + 1
    End If
    Cells(iLastRow,"A").Value = Format(Date,"dd mmm yyyy")


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Roger Govier" <roger@nospamtechnology4u.co.uk> wrote in message
    news:436A83D3.8080402@nospamtechnology4u.co.uk...
    > A couple of typos.
    > What Bob meant to type was
    >
    > Dim iLastRow as Long
    >
    > iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    > If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Then
    > 'do nothing
    > Else
    > iLastRow = iLastRow + 1
    > Cells(iLastRow,"A").Value = Format(Date,"dd mmm yyyy")
    > End If
    >
    >
    > Regards
    >
    > Roger Govier
    >
    >
    > Bob Phillips wrote:
    > > Dim iLastRow as Long
    > >
    > > iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    > > If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Tyhen
    > > 'do nothing
    > > Else
    > > iLastRow = iLastRow + 1
    > > Cells(iNextRow,"A").Value = Format(Date,"dd mmm yyyy")
    > > End If
    > >




  5. #5
    Roger Govier
    Guest

    Re: Excel Macros

    Hadn't spotted that one Bob<g>

    Regards

    Roger Govier


    Bob Phillips wrote:
    > Thanks Roger, but there is a also a logic error. Should be
    >
    > Dim iLastRow as Long
    >
    > iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
    > If iLastRow = 1 And Cells(iLastRow,"A").Value = "" Then
    > 'do nothing
    > Else
    > iLastRow = iLastRow + 1
    > End If
    > Cells(iLastRow,"A").Value = Format(Date,"dd mmm yyyy")
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0