Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Complie error

Hi,

I am having a problem with some code..... It's from a teaching book as
I try to learn VBA. I have written it exactly as in the book but I get
a complie error, any Ideas ?

..Range("D2).Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"

The error msg is :-

Compile Error
Expected list separator or )

The whole code is :-

Private Sub cmdCalculate_Click()
'__________________________
'Add Formulas for summary stats
'__________________________

With ActiveSheet
'These formulas are entered int the new worksheet.
..Range("D2).Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"
..Range("D3).Formula = "=MIN(" & ActiveWindow.Selection.Address & ")"
..Range("D4).Formula = "=MAX(" & ActiveWindow.Selection.Address & ")"
..Range("D5).Formula = "=SUM(" & ActiveWindow.Selection.Address & ")"
..Range("D6).Formula = "=AVERAGE(" & ActiveWindow.Selection.Address &
")"
..Range("D7).Formula = "=STDEV(" & ActiveWindow.Selection.Address & ")"

'____________________________
'Add labels and stats
'___________________________

..Range("C2").Value = "Count:"
..Range("C3").Value = "Min:"
..Range("C4").Value = "Max:"
..Range("C5").Value = "Sum:"
..Range("C6").Value = "Average:"
..Range("C7").Value = "Stand Dev:"
..Range("C2:D7").Select

End With

'____________________________

'Format the labels and stats.

'___________________________

With Selection
..Font.Size = 16
..Font.Bold = True
..Font.Color = vbBlue
..Font.Name "Arial"
..Columns.AutoFit
..Interior.Color = vbGreen
..Borders.Weight = x1Thick
..Borders.Color = vbRed
End With
Range("A1").Select

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Complie error

You are missing a closing quote in the range address

..Range("D2").Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"

^
..................||.......................

(hopefully that works)


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Decreenisi" wrote in message
...
Hi,

I am having a problem with some code..... It's from a teaching book as
I try to learn VBA. I have written it exactly as in the book but I get
a complie error, any Ideas ?

.Range("D2).Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"

The error msg is :-

Compile Error
Expected list separator or )

The whole code is :-

Private Sub cmdCalculate_Click()
'__________________________
'Add Formulas for summary stats
'__________________________

With ActiveSheet
'These formulas are entered int the new worksheet.
.Range("D2).Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"
.Range("D3).Formula = "=MIN(" & ActiveWindow.Selection.Address & ")"
.Range("D4).Formula = "=MAX(" & ActiveWindow.Selection.Address & ")"
.Range("D5).Formula = "=SUM(" & ActiveWindow.Selection.Address & ")"
.Range("D6).Formula = "=AVERAGE(" & ActiveWindow.Selection.Address &
")"
.Range("D7).Formula = "=STDEV(" & ActiveWindow.Selection.Address & ")"

'____________________________
'Add labels and stats
'___________________________

.Range("C2").Value = "Count:"
.Range("C3").Value = "Min:"
.Range("C4").Value = "Max:"
.Range("C5").Value = "Sum:"
.Range("C6").Value = "Average:"
.Range("C7").Value = "Stand Dev:"
.Range("C2:D7").Select

End With

'____________________________

'Format the labels and stats.

'___________________________

With Selection
.Font.Size = 16
.Font.Bold = True
.Font.Color = vbBlue
.Font.Name "Arial"
.Columns.AutoFit
.Interior.Color = vbGreen
.Borders.Weight = x1Thick
.Borders.Color = vbRed
End With
Range("A1").Select

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Complie error

Range("D2").

You missed a quote

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Decreenisi" wrote in message ...
| Hi,
|
| I am having a problem with some code..... It's from a teaching book as
| I try to learn VBA. I have written it exactly as in the book but I get
| a complie error, any Ideas ?
|
| .Range("D2).Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"
|
| The error msg is :-
|
| Compile Error
| Expected list separator or )
|
| The whole code is :-
|
| Private Sub cmdCalculate_Click()
| '__________________________
| 'Add Formulas for summary stats
| '__________________________
|
| With ActiveSheet
| 'These formulas are entered int the new worksheet.
| .Range("D2).Formula = "=COUNT(" & ActiveWindow.Selection.Address & ")"
| .Range("D3).Formula = "=MIN(" & ActiveWindow.Selection.Address & ")"
| .Range("D4).Formula = "=MAX(" & ActiveWindow.Selection.Address & ")"
| .Range("D5).Formula = "=SUM(" & ActiveWindow.Selection.Address & ")"
| .Range("D6).Formula = "=AVERAGE(" & ActiveWindow.Selection.Address &
| ")"
| .Range("D7).Formula = "=STDEV(" & ActiveWindow.Selection.Address & ")"
|
| '____________________________
| 'Add labels and stats
| '___________________________
|
| .Range("C2").Value = "Count:"
| .Range("C3").Value = "Min:"
| .Range("C4").Value = "Max:"
| .Range("C5").Value = "Sum:"
| .Range("C6").Value = "Average:"
| .Range("C7").Value = "Stand Dev:"
| .Range("C2:D7").Select
|
| End With
|
| '____________________________
|
| 'Format the labels and stats.
|
| '___________________________
|
| With Selection
| .Font.Size = 16
| .Font.Bold = True
| .Font.Color = vbBlue
| .Font.Name "Arial"
| .Columns.AutoFit
| .Interior.Color = vbGreen
| .Borders.Weight = x1Thick
| .Borders.Color = vbRed
| End With
| Range("A1").Select
|
| End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complie Error with xlValues vincent_vega Excel Programming 1 July 15th 06 07:21 PM
VB Complie error - can You Help Anthony Excel Programming 2 October 9th 05 10:51 PM
Complie Error Help JMay Excel Programming 4 January 24th 05 04:33 AM
complie error brian Excel Programming 2 December 13th 04 06:51 PM
Complie Error chris huber Excel Programming 3 January 14th 04 09:57 AM


All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"