ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Need help with Application.WorksheetFunction (https://www.excelbanter.com/excel-discussion-misc-queries/187458-need-help-application-worksheetfunction.html)

Ayo

Need help with Application.WorksheetFunction
 
Worksheets(1).Select
With Selection
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20")
.Range("C21").Value = Application.WorksheetFunction.Sum("C17:C20")
.Range("D21").Value = Application.WorksheetFunction.Sum("D17:D20")
.Range("F21").Value = Application.WorksheetFunction.Sum("F17:F20")
End With

What am I doing wrong here. I keep getting an error on this line
..Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20").
I also get an error on ":" when I tried
..Range("B21").Value = Application.WorksheetFunction.Sum(B17:B20)

Gary''s Student

Need help with Application.WorksheetFunction
 
Sub hfska()
Worksheets(1).Select
With Selection
..Range("B21").Value = Application.WorksheetFunction.Sum(Range("B17:B20") )
..Range("C21").Value = Application.WorksheetFunction.Sum(Range("C17:C20") )
..Range("D21").Value = Application.WorksheetFunction.Sum(Range("D17:D20") )
..Range("F21").Value = Application.WorksheetFunction.Sum(Range("F17:F20") )
End With
End Sub

In VBA SUM() needs a real range.
--
Gary''s Student - gsnu200786


"Ayo" wrote:

Worksheets(1).Select
With Selection
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20")
.Range("C21").Value = Application.WorksheetFunction.Sum("C17:C20")
.Range("D21").Value = Application.WorksheetFunction.Sum("D17:D20")
.Range("F21").Value = Application.WorksheetFunction.Sum("F17:F20")
End With

What am I doing wrong here. I keep getting an error on this line
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20").
I also get an error on ":" when I tried
.Range("B21").Value = Application.WorksheetFunction.Sum(B17:B20)


Ayo

Need help with Application.WorksheetFunction
 
Thanks Gary's student.
I will try that.

"Gary''s Student" wrote:

Sub hfska()
Worksheets(1).Select
With Selection
.Range("B21").Value = Application.WorksheetFunction.Sum(Range("B17:B20") )
.Range("C21").Value = Application.WorksheetFunction.Sum(Range("C17:C20") )
.Range("D21").Value = Application.WorksheetFunction.Sum(Range("D17:D20") )
.Range("F21").Value = Application.WorksheetFunction.Sum(Range("F17:F20") )
End With
End Sub

In VBA SUM() needs a real range.
--
Gary''s Student - gsnu200786


"Ayo" wrote:

Worksheets(1).Select
With Selection
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20")
.Range("C21").Value = Application.WorksheetFunction.Sum("C17:C20")
.Range("D21").Value = Application.WorksheetFunction.Sum("D17:D20")
.Range("F21").Value = Application.WorksheetFunction.Sum("F17:F20")
End With

What am I doing wrong here. I keep getting an error on this line
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20").
I also get an error on ":" when I tried
.Range("B21").Value = Application.WorksheetFunction.Sum(B17:B20)


Mike H

Need help with Application.WorksheetFunction
 
You haven't selected anything (except a worksheet) so don't use 'With
Selection' it's simpler than that

Sub standard()
Worksheets(1).Select
Range("B21").Value = Application.WorksheetFunction.Sum(Range("B17: B20"))
Range("C21").Value = Application.WorksheetFunction.Sum(Range("C17:C20") )
Range("D21").Value = Application.WorksheetFunction.Sum(Range("D17:D20") )
Range("F21").Value = Application.WorksheetFunction.Sum(Range("F17:F20") )
End Sub

Mike

"Ayo" wrote:

Worksheets(1).Select
With Selection
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20")
.Range("C21").Value = Application.WorksheetFunction.Sum("C17:C20")
.Range("D21").Value = Application.WorksheetFunction.Sum("D17:D20")
.Range("F21").Value = Application.WorksheetFunction.Sum("F17:F20")
End With

What am I doing wrong here. I keep getting an error on this line
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20").
I also get an error on ":" when I tried
.Range("B21").Value = Application.WorksheetFunction.Sum(B17:B20)


Don Guillett

Need help with Application.WorksheetFunction
 
No selections. Notice the . before range in BOTH cases

Sub sumem()
With Worksheets("sheet11")
.Range("d1").Value = Application.Sum(.Range("c2:c22"))
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ayo" wrote in message
...
Worksheets(1).Select
With Selection
.Range("B21").Value =
Application.WorksheetFunction.Sum("B17:B20")
.Range("C21").Value =
Application.WorksheetFunction.Sum("C17:C20")
.Range("D21").Value =
Application.WorksheetFunction.Sum("D17:D20")
.Range("F21").Value =
Application.WorksheetFunction.Sum("F17:F20")
End With

What am I doing wrong here. I keep getting an error on this line
.Range("B21").Value = Application.WorksheetFunction.Sum("B17:B20").
I also get an error on ":" when I tried
.Range("B21").Value = Application.WorksheetFunction.Sum(B17:B20)




All times are GMT +1. The time now is 09:00 AM.

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