![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 38
|
this s part of a larger formula:
Dim c For Each c In Range("C1:C" & x) If c = "" Then MsgBox "Please enter data in cell " & c.Address c.Select Exit Sub End If Dim x As Integer, counter As Integer, y As Integer, MyArr Randomize MyArr = Array(4, 8, 16, 32, 64, 128, 256) when i try and execute the macro i get this message "Compile error : Duplicate declaration in current scope". And also the line "Dim x as Interger" get highlited. How should i stop this from happening? [ This Message was edited by: MERKY on 2002-05-02 10:54 ] |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
You need to dimension x before you use it.
Plus, it's a good practice to do all of your dimension at the beginning of the program. The reason for this is that the first time you refer to x, VBA dimensions it as a variant type. So when you dimension it again later, it gives an error. K |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Posts: 85
|
you could also try declaring you var's like so:
Dim var1, var2, var3 as integer Also the variable "Counter" you have listed may be a built in function so hence "Duplicate Declaration in Scope" Not 100% sure about that but try "Coun1" or something different. Regards and good luck! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|