how do i write data to a specific cell in excel?
thanks
Liam
Printable View
how do i write data to a specific cell in excel?
thanks
Liam
try this..
Activecell.value = "myText"
if that doesn't work, you should provide more details of what you are really trying to accomplish. :)
or try this:
Code:Range("A10").Value = "VB-World" 'replace a10 with what cell you want.
Isn't ActiveCell.Value reading out? I thought that giving a cell data is done by ActiveCell.FormulaR1C1 = "blabla"...
activecell.value can be used to get the active cell's value or to set it
i.e
msgbox activecell.value
would show the activecells value
activecell.value = "Hey"
set the activecells value to "Hey"
There are a number of accessing cells in an excel worksheet:
Reference Meaning
Range("A1") Cell A1
Range("A1:B5") Cells A1 through B5
Range("C5:D9,G9:H16") A multiple-area selection
Range("A:A") Column A
Range("1:1") Row one
Range("A:C") Columns A through C
Range("1:5") Rows one through five
Range("1:1,3:3,8:8") Rows one, three, and eight
Range("A:A,C:C,F:F") Columns A, C, and F
OR
Worksheets("Sheet1").Cells(6, 1).Value = 10
OR
Reference Meaning
Rows(1) Row one
Rows All the rows on the worksheet
Columns(1) Column one
Columns("A") Column one
Columns All the columns on the worksheet
e.g.
ORCode:Sub SeveralRows()
Worksheets("Sheet1").Activate
Dim myUnion As Range
Set myUnion = Union(Rows(1), Rows(3), Rows(5))
myUnion.Font.Bold = True
End Sub
Worksheets("Sheet1").[A1:B5].ClearContents
For more help start excel, on the visual basic toolbar click the visual basic editor button. click on help and type
'referencing cells' in the office assistant, click Search.
That should give you an link of 'How to reference cells and ranges'. There is a lot of help in there.