+ Reply to Thread
Results 1 to 5 of 5

Update cell value based on fixed and variable value

  1. #1
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Question Update cell value based on fixed and variable value

    Hi,

    I have a variable with a year called RYear which, for this example, has a value of 2013. I want my cell value to be "Period = 2013"

    I want the macro to update the cell value with the following kind of code:

    Range("A9") = "Period = " + RYear

    However, that gives me a Run-time error '13' Type mismatch.

    How do I have to change this line to make it work?

    RYear is an integer if that matters.
    Last edited by The Phil; 01-08-2014 at 08:27 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,755

    Re: Update cell value based on fixed and variable value

    Try this:

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Try this !

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Update cell value based on fixed and variable value

    In the line of code you provided, change the + (plus sign) to & (ampersand)
    Just a guy trying to make work stuff easier.

  5. #5
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Update cell value based on fixed and variable value

    That was simple. Thanks guys!

+ 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. Replies: 2
    Last Post: 11-22-2011, 12:33 PM
  2. linked cell - variable rather than fixed?
    By FirePig in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-21-2008, 05:30 PM
  3. From a fixed cell to a variable
    By daniroy@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-21-2006, 09:20 AM
  4. Replies: 0
    Last Post: 05-24-2005, 06:31 AM
  5. Replies: 0
    Last Post: 05-23-2005, 07:06 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