+ Reply to Thread
Results 1 to 6 of 6

How to insert formula into a column of cells within a list of data

  1. #1
    Registered User
    Join Date
    12-30-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    How to insert formula into a column of cells within a list of data

    Hello!

    Need help on macro. Currently, I am writing a macro to populate results into a newly inserted column C (date and time) after I captured info from column A (dates) and column B (time) for a list of data that could easily go beyond thousands row of records.

    So far, I managed to find a way to insert of a new column and get the result that I want for one row. However, I do not know how to apply the formula for every single cell until the very last row of data in the list.

    This is what I have so far:
    Please Login or Register  to view this content.
    What I'm trying to do: I insert a new column and a title at the first cell of the column. Then, using a Do Until loop I generate results for the whole list of data by combining info from column A (date) and column B (time) into the newly created column C (date and time) and change the format of the cell. A check was also done using the IF ELSE loop to leave the cell empty if there is no data in column A.

    I tried running the above codes but it gives me error at line 5/6. I could have used the wrong syntax to check for empty cells but I do not know what should I use to declare instead. I had also tried running the above codes by commenting codes to test whether the formula works on a single cell and it did. However, due to my limited knowledge on macro/vba, I was unable to continue my coding to get the results that I want. Please advice. ):

    I had also posted on another forum previously (www.excelblog.co.uk/forums/t/3221.aspx) but I have not received any replies yet so I decided to post another thread on this forum. I might have used the wrong term but please forgive me as I am very new to excel (started a few days ago). Thank you in advance (:
    Last edited by potato; 01-03-2012 at 09:02 PM.
    Cheers,
    Pauline the potato

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: How to insert formula into a column of cells within a list of data

    You could use this code:
    Please Login or Register  to view this content.
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    12-30-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to insert formula into a column of cells within a list of data

    Sorry for the late reply. What will happen when there are blank cells in either column A or B? Do you mind explaining the need to transform the formula to values? I am currently reading up on macro but am still quite confused even though I work using vb in the past. Really Thanks for your help (:

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: How to insert formula into a column of cells within a list of data

    What will happen when there are blank cells in either column A or B
    It will work fine as long as column A has the largest number of used cells (See attachment). I haven't checked the formula just the autofill as you will see.

    Do you mind explaining the need to transform the formula to values?
    It depends what you need to do with the column afterwards. I would change it to values for instance if I needed to do a sort on the column afterwards or obviously if I wanted to fix the result.
    It is up to you whether you want to change it to values or not again depending on what you need to do afterwards. It is not necessary for the formula fill.

    HTH
    Attached Files Attached Files
    Last edited by WasWodge; 01-02-2012 at 02:44 AM.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  5. #5
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: How to insert formula into a column of cells within a list of data

    I have looked at the formula now and the results of putting in spaces is as attached.
    HTH
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    12-30-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to insert formula into a column of cells within a list of data

    Hey thanks for the help and explanation. Really appreciate it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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