Tags: assign, cell, clear, code, excel, microsoft, msdn, newbie, pseudo, selecting, software, value, vba

How to: assign a value to a cell without selecting the cell first

On Microsoft » Microsoft Excel

2,365 words with 4 Comments; publish: Fri, 23 May 2008 03:46:00 GMT; (306117.19, « »)

Hi,

Its clear that I am still a newbie...

In VBA, how do I assign a value to a cell with out first selecting the cell?

In pseudo code I would describe it as "Assign the value 5 to the cell in

location x".

Kind regards

George

All Comments

Leave a comment...

  • 4 Comments
    • try

      cells(1,5)=5

      or

      range("a5")=5

      --

      Don Guillett

      SalesAid Software

      dguillett1.excel.questionfor.info.austin.rr.com

      "George Furnell" <GeorgeFurnell.excel.questionfor.info.discussions.microsoft.com> wrote in message

      news:C790DE33-FA21-4922-936B-B3A6A1A1B048.excel.questionfor.info.microsoft.com...

      > Hi,

      > Its clear that I am still a newbie...

      > In VBA, how do I assign a value to a cell with out first selecting the

      > cell?

      > In pseudo code I would describe it as "Assign the value 5 to the cell in

      > location x".

      > Kind regards

      > George

      #1; Fri, 23 May 2008 03:47:00 GMT
    • In the simplest form: Cells({row},{column}).value=5

      More explicitly: Worksheets({worksheet id}).Cells({row},{column}).value=5

      --

      Regards,

      Tushar Mehta

      www.tushar-mehta.com

      Excel, PowerPoint, and VBA add-ins, tutorials

      Custom MS Office productivity solutions

      In article <C790DE33-FA21-4922-936B-B3A6A1A1B048.excel.questionfor.info.microsoft.com>,

      GeorgeFurnell.excel.questionfor.info.discussions.microsoft.com says...

      > Hi,

      > Its clear that I am still a newbie...

      > In VBA, how do I assign a value to a cell with out first selecting the cell?

      > In pseudo code I would describe it as "Assign the value 5 to the cell in

      > location x".

      > Kind regards

      > George

      >

      #2; Fri, 23 May 2008 03:49:00 GMT
    • Range("A1").Value = 1

      It is also good practice to reference the workbook and worksheet

      With Activeworkbook

      With .Worksheets("Sheet1")

      .Range("A1").Value = 5

      ...

      End With

      End With

      note the leading dots

      --

      HTH

      Bob Phillips

      (remove nothere from the email address if mailing direct)

      "George Furnell" <GeorgeFurnell.excel.questionfor.info.discussions.microsoft.com> wrote in message

      news:C790DE33-FA21-4922-936B-B3A6A1A1B048.excel.questionfor.info.microsoft.com...

      > Hi,

      > Its clear that I am still a newbie...

      > In VBA, how do I assign a value to a cell with out first selecting the

      cell?

      > In pseudo code I would describe it as "Assign the value 5 to the cell in

      > location x".

      > Kind regards

      > George

      #3; Fri, 23 May 2008 03:50:00 GMT
    • Thank you, thats what I was looking for.

      Kind regards

      George

      #4; Fri, 23 May 2008 03:50:00 GMT