ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unable to write to a cell (https://www.excelbanter.com/excel-programming/394318-unable-write-cell.html)

David A.[_2_]

Unable to write to a cell
 
I am having surprising difficulting wriiting to a cell within a worksheet. I
have tried various approaches and have receive the same erro on all attempts;
Code below

Set rawRange = Range("B5")
rawRange.Value = "data"

Or

ActiveWorkbook.Worksheets("test1").Cells(2, 2).Value = "Please work"

in the first example I can read the data out via the immediate window, but
can't write out..
I get this error "Application-defined or object-defined error" Please help!!!




Thomas

Unable to write to a cell
 
David,

try this:

Range("B5").Value = "Try this"

If you want to operate with variables (rowRange etc.) you have to define
them first (Dim rowRange as LOng)


"David A." wrote:

I am having surprising difficulting wriiting to a cell within a worksheet. I
have tried various approaches and have receive the same erro on all attempts;
Code below

Set rawRange = Range("B5")
rawRange.Value = "data"

Or

ActiveWorkbook.Worksheets("test1").Cells(2, 2).Value = "Please work"

in the first example I can read the data out via the immediate window, but
can't write out..
I get this error "Application-defined or object-defined error" Please help!!!




Halim

Unable to write to a cell
 
David,

Try this sub:
Sub addata()
Dim rawRange as Range ' It's important to define as Range _
instead of other define

Set rawRange = Range("B5")
rawRange.Value = "data"

End Sub


--
Regards,

Halim



"Thomas" wrote:

David,

try this:

Range("B5").Value = "Try this"

If you want to operate with variables (rowRange etc.) you have to define
them first (Dim rowRange as LOng)


"David A." wrote:

I am having surprising difficulting wriiting to a cell within a worksheet. I
have tried various approaches and have receive the same erro on all attempts;
Code below

Set rawRange = Range("B5")
rawRange.Value = "data"

Or

ActiveWorkbook.Worksheets("test1").Cells(2, 2).Value = "Please work"

in the first example I can read the data out via the immediate window, but
can't write out..
I get this error "Application-defined or object-defined error" Please help!!!





All times are GMT +1. The time now is 05:27 PM.

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