+ Reply to Thread
Results 1 to 6 of 6

Set cell value by macro not a formula

  1. #1
    Registered User
    Join Date
    10-01-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    42

    Set cell value by macro not a formula

    I want to set the value of a cell when running a macro, if the macro is not run the cell is blank and can be free format entry.

    In the attached example I want to set the value of cell A1 on Sheet 1 when I run the macro. The value will be based on using the value in Cell F1 to lookup the the value in the table in sheet 2 column C where the value in Column A matches that value.

    Hope that makes sense

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Set cell value by macro not a formula

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    Please Login or Register  to view this content.
    As per your requirement I covered both (i.e.) Not used Formula directly and loaded it in Macro


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Set cell value by macro not a formula

    Hi Chivers,
    Welcome to the Forum.
    You try this.....
    Please Login or Register  to view this content.
    You can change the sheet names if required.
    Please find the attached sheet and click on the Green Button on Sheet1 to get the desired output in A1.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    10-01-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    42

    Re: Set cell value by macro not a formula

    Thank you SixthSense & sktneer for your quick responses, I will try them when I am back in the office tomorrow and let you know if all OK.

  5. #5
    Registered User
    Join Date
    10-01-2014
    Location
    Birmingham, England
    MS-Off Ver
    2010
    Posts
    42

    Re: Set cell value by macro not a formula

    Thanks again guys, both methods worked so I am closing the thread.

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Set cell value by macro not a formula

    You're welcome and thanks for the feedback as well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Macro: Plugging an Array-Formula into a Cell and Dragging Formula Down Columns
    By Brianandstewie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2013, 02:57 PM
  2. [SOLVED] VBA macro to check if one cell has text and paste a formula in a different cell
    By vitt4300 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2013, 01:38 PM
  3. Macro error, Formula cell showing a green triangle in top cell
    By sherry_1991 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2013, 02:09 PM
  4. Replies: 1
    Last Post: 10-14-2012, 12:23 AM
  5. Replies: 1
    Last Post: 07-20-2006, 03:05 PM

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