Unable to write to a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!!!
 
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,

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top