Set Worksh = Worksheets("SampleWorksheet")
Set myRange = Worksh.Range("F1")
msgbox myRange.Value, , ""   'WORKS: current value in "F1" cell is displayed 
myRange.Value = 100            'DOESNT WORK! : value in cell DOES NOT change

I have no idea - it was supposed to work. Any ideas? Thanks

Re: Excel: Can't set value in cell 80 80

Are you saving the document?? the following code will work:

Private Sub Command1_Click()

Dim xl
Dim Worksh
Dim xlwbook
    Set xl = CreateObject("Excel.Application")
    Set xlwbook = xl.Workbooks.Open("C:\temp.xls")
    Set Worksh = xlwbook.Sheets.Item(1)
    xl.Visible = True
    Set myRange = Worksh.Range("F1")
    MsgBox myRange.Value, , ""
    myRange.Value = 100
    xl.ActiveWorkbook.Close False, "C:\temp.xls"
End Sub
Re: Excel: Can't set value in cell 80 80

My code is very simmilar but is in function not in sub. May it be the problem? Maybe from functions you can't edit other cells but the one the function is returning it's value to (the one with formula "=MyFunction() ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.