+ Reply to Thread
Results 1 to 5 of 5

assign a value to a named variable of a spread sheet

  1. #1
    Registered User
    Join Date
    01-20-2013
    Location
    Chicago, US
    MS-Off Ver
    Excel 2010
    Posts
    4

    assign a value to a named variable of a spread sheet

    Hello All:

    I am a 1 day old newbie on the forum ...so advance apologies if I do not follow the norms ....will bide by the rules soon ...
    Have a spreadsheet 'sheet 2' in which I have a named variable "num_1". I was looking for VBA code to assign the value from cell (say "A3") on 'sheet 1' to the named variable "num_2" on sheet 2 while maintaining the integrity of the named variable.

    I use the following code but this erases the named variable "num_1" completely from 'sheet 2'
    Sheets("sheet 2").Names("num_1").Value = Sheets("sheet 1").Range("A3").value

    Thank you!

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: assign a value to a named variable of a spread sheet

    Try this
    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    01-20-2013
    Location
    Chicago, US
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: assign a value to a named variable of a spread sheet

    Thanks Mike!
    That worked...

  4. #4
    Registered User
    Join Date
    08-16-2011
    Location
    Lancaster, Pennsylvania
    MS-Off Ver
    365 2016
    Posts
    5

    Re: assign a value to a named variable of a spread sheet

    Mike, this problem is similar to one I am having only I have the possibility of the value passed from A3 as being a blank with a blank being an accepable value.
    aka when the field is a blank it means the country is the default or USA. So blank happens a lot.
    Unfortunately it causes the code recieving this answer to die.
    It's an SQL query. Any thoughts?

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: assign a value to a named variable of a spread sheet

    Teddytim

    I would like to ask for you to take a look to forum rules. There you'll find anything you need as per example how to use code tags(rule 3) or to don't . Don't post a question in the thread of another member(rule 2).

    I also put a link of your thread in case that someone is interest.

    http://www.excelforum.com/excel-prog...-if-blank.html
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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