PC Review


Reply
Thread Tools Rate Thread

Complie error

 
 
Decreenisi
Guest
Posts: n/a
 
      6th Dec 2007
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("C27").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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      6th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:df4d47de-9381-44fc-b6a7-(E-Mail Removed)...
> 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("C27").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 With Quote
 
Niek Otten
Guest
Posts: n/a
 
      6th Dec 2007
Range("D2").

You missed a quote

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Decreenisi" <(E-Mail Removed)> wrote in message news:df4d47de-9381-44fc-b6a7-(E-Mail Removed)...
| 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("C27").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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
complie error:next without for Walter Microsoft Access Form Coding 3 11th Dec 2008 07:36 PM
complie error SDDzuro Microsoft Excel New Users 0 9th Dec 2007 11:12 PM
VB Complie error - can You Help =?Utf-8?B?QW50aG9ueQ==?= Microsoft Excel Programming 2 9th Oct 2005 10:51 PM
complie error =?Utf-8?B?YnJpYW4=?= Microsoft Excel Programming 2 13th Dec 2004 06:51 PM
Complie Error chris huber Microsoft Excel Programming 3 14th Jan 2004 09:57 AM


Features
 

Advertising
 

Newsgroups
 


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