range and sum?

O

Ole

Hi NG.

I have the following code:

""Sub Makro1()

Dim bClose As Boolean
Dim bk As Workbook
On Error Resume Next
Set bk = Workbooks("Master.xls")
On Error GoTo 0
If bk Is Nothing Then
bClose = True
Set bk = Workbooks.Open("C:\Master.xls")
End If
bk.Worksheets(1).Range("A1).Value = _
Worksheets(1).Range(A1).Value
bk.Save
If bClose Then
bk.Close Savechanges:=False
End If
Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True

End Sub""

Now i want to copy the SUM of A38 and A41 to my master.xls, but everything
i
tries failes. someting like this:

bk.Worksheets(1).Range("A1").Value = _
Worksheets(1).Range(=SUM("A38;A41")).Value

I have tried many other things but nothing works, btw. its numbers i have
to
sum.

I hope you have an idea.

Regards,
Ole
 
B

Bob Phillips

bk.Worksheets(1).Range("A1").Value = _
Worksheets(1).Range("A38").Value + Worksheets(1).Range(";A41").Value


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
O

Ole

Bob Phillips said:
bk.Worksheets(1).Range("A1").Value = _
Worksheets(1).Range("A38").Value + Worksheets(1).Range(";A41").Value
Hi Bob,

I have tried it, but get a message box saying:

"Microsoft visual basic:

Error 400"

Got any ideas.

Ole
 
O

Ole

"Ole" <[email protected]> skrev i en meddelelse
Hi Bob,
I have tried it, but get a message box saying:

"Microsoft visual basic:

Error 400"

Got any ideas.

Ole

And when i run it from inside VBA i get:

"Run-time error '1004';

Application-defined or object-defined error"

Ole
 
B

Bob Phillips

I left a stupid ; in there. Try

bk.Worksheets(1).Range("A1").Value = _
Worksheets(1).Range("A38").Value + Worksheets(1).Range("A41").Value

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
O

Ole

Bob Phillips said:
I left a stupid ; in there. Try

bk.Worksheets(1).Range("A1").Value = _
Worksheets(1).Range("A38").Value + Worksheets(1).Range("A41").Value

Thanks Bob,

Its works perfect :)

Ole
 

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

Top