ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to: assign a value to a cell without selecting the cell first (https://www.excelbanter.com/excel-programming/351188-how-assign-value-cell-without-selecting-cell-first.html)

George Furnell[_2_]

How to: assign a value to a cell without selecting the cell first
 
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

Don Guillett

How to: assign a value to a cell without selecting the cell first
 
try
cells(1,5)=5
or
range("a5")=5

--
Don Guillett
SalesAid Software

"George Furnell" wrote in message
...
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




Tushar Mehta

How to: assign a value to a cell without selecting the cell first
 
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 ,
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


Bob Phillips[_6_]

How to: assign a value to a cell without selecting the cell first
 
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" wrote in message
...
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




George Furnell[_2_]

How to: assign a value to a cell without selecting the cell fi
 
Thank you, thats what I was looking for.

Kind regards

George


All times are GMT +1. The time now is 05:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com