+ Reply to Thread
Results 1 to 3 of 3

VBA to detect next empty cell in column and add formula, then repeat for next column, ...

  1. #1
    Forum Contributor
    Join Date
    12-18-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    108

    VBA to detect next empty cell in column and add formula, then repeat for next column, ...

    Hi,

    I'm working on automatically populating data into a report, and just when i thought I figured it out, it doesn't seem to work....
    I have 7 columns where, at the bottom of each folumn - in the first empty cell, I need to enter a formula.

    I've come up with the below, but the repetative 'Dim Lastrow as Long' is not appreciated by Excel.
    Also, for some reason it is not shifting columns, while it should...... (all formula's are entered on column A)

    Anyone have any brilliant thoughts on this one?


    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: VBA to detect next empty cell in column and add formula, then repeat for next column,

    Hi, Marijke,

    as you have noted it´s good enough to once Dim the variable. The reason for not shifting is the use of ActiveCell in every formula which should be inserted.

    Your code may look like this:
    Please Login or Register  to view this content.
    Inserting a volatile Function like Now() as a formula might not show the result I would expect from it as the DateTimeStamp would update on any calculation. As the formulas should be inserted into the very same row you may use a code like
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    12-18-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 365
    Posts
    108

    Re: VBA to detect next empty cell in column and add formula, then repeat for next column,

    Thanks Holger,
    I've used the 2nd code you have put in and my report runs perfectly!

+ 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.6.0 RC 1