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

I am trying to create a form for easy input. Since a lot of the input is
fairly similar, i prefer using a loop. the problem is inputting a change of
string so i can actually achive data from the text boxes:

Private Sub add_day_Click()

Dim r, c As Integer
Dim SOLD As Integer
Dim Cash, Credit, Check As Currency
Dim ws As Worksheet
Dim Mall As String
Dim day As Integer
Dim days As String
Dim Response
Dim Product


Mall = ""
day = 0
If Me.txt_mall.Value < "" Then Mall = Me.txt_mall.Value
If Me.txt_day.Value < "" Then day = Me.txt_day.Value
If Mall < "" And day < 0 Then
Select Case day
Case 1 To 7
days = " 1-7"
Case 8 To 14
days = " 8-14"
Case 15 To 21
days = " 15-21"
Case 22 To 28
days = " 22-28"
Case 29 To 31
days = " 29-31"
End Select

Mall = Mall + days

Set ws = Worksheets(Mall)


'copy the data to the database
For j = 1 To 3
For i = 2 To 74 Step 6
Select Case i
Case 2
Product = Worksheets("Intro").Cells(11, 1).Value
Case 8
Product = Worksheets("Intro").Cells(12, 1).Value
Case 14
Product = Worksheets("Intro").Cells(13, 1).Value
Case 20
Product = Worksheets("Intro").Cells(14, 1).Value
Case 26
Product = Worksheets("Intro").Cells(15, 1).Value
Case 32
Product = Worksheets("Intro").Cells(16, 1).Value
Case 38
Product = Worksheets("Intro").Cells(17, 1).Value
Case 44
Product = Worksheets("Intro").Cells(18, 1).Value
Case 50
Product = Worksheets("Intro").Cells(19, 1).Value
Case 56
Product = Worksheets("Intro").Cells(20, 1).Value
Case 62
Product = Worksheets("Intro").Cells(21, 1).Value
Case 68
Product = Worksheets("Intro").Cells(22, 1).Value
Case 74
Product = Worksheets("Intro").Cells(23, 1).Value
End Select

Select Case j
Case 1
Product = Product + "_add"
ws.Cells(i + j, c).Value = Me.Product.Value <---- This is
where i get the error. It will not allow me to use "Product" since it's not
one of the text boxes

Me.Product.ClearContents
Case 2
Product = Product + "_sold"
ws.Cells(i + j, c).Value = Me.Product.Value
Me.Product.ClearContents
End If
Case 3
' Product = Product + "_damage"
' If Not IsEmpty(Me.Product) Then
' ws.Cells(i + j, c).Value = Me.Product.Value
' Me.Product.ClearContents
' End If
End Select
Next i
Next j
Else
Response = MsgBox("You Did Not Enter The Mall / Date, Please Enter
Again", vbExclamation, "Missing Information")
End If
End Sub

Help Thanks
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 58
Default compile error

Product is just your variable, correct? Try removing the me keyword
that prefaces it.

Ken Puls, CMA - Microsoft MVP (Excel)
www.excelguru.ca

Jared wrote:
I am trying to create a form for easy input. Since a lot of the input is
fairly similar, i prefer using a loop. the problem is inputting a change of
string so i can actually achive data from the text boxes:

Private Sub add_day_Click()

Dim r, c As Integer
Dim SOLD As Integer
Dim Cash, Credit, Check As Currency
Dim ws As Worksheet
Dim Mall As String
Dim day As Integer
Dim days As String
Dim Response
Dim Product


Mall = ""
day = 0
If Me.txt_mall.Value < "" Then Mall = Me.txt_mall.Value
If Me.txt_day.Value < "" Then day = Me.txt_day.Value
If Mall < "" And day < 0 Then
Select Case day
Case 1 To 7
days = " 1-7"
Case 8 To 14
days = " 8-14"
Case 15 To 21
days = " 15-21"
Case 22 To 28
days = " 22-28"
Case 29 To 31
days = " 29-31"
End Select

Mall = Mall + days

Set ws = Worksheets(Mall)


'copy the data to the database
For j = 1 To 3
For i = 2 To 74 Step 6
Select Case i
Case 2
Product = Worksheets("Intro").Cells(11, 1).Value
Case 8
Product = Worksheets("Intro").Cells(12, 1).Value
Case 14
Product = Worksheets("Intro").Cells(13, 1).Value
Case 20
Product = Worksheets("Intro").Cells(14, 1).Value
Case 26
Product = Worksheets("Intro").Cells(15, 1).Value
Case 32
Product = Worksheets("Intro").Cells(16, 1).Value
Case 38
Product = Worksheets("Intro").Cells(17, 1).Value
Case 44
Product = Worksheets("Intro").Cells(18, 1).Value
Case 50
Product = Worksheets("Intro").Cells(19, 1).Value
Case 56
Product = Worksheets("Intro").Cells(20, 1).Value
Case 62
Product = Worksheets("Intro").Cells(21, 1).Value
Case 68
Product = Worksheets("Intro").Cells(22, 1).Value
Case 74
Product = Worksheets("Intro").Cells(23, 1).Value
End Select

Select Case j
Case 1
Product = Product + "_add"
ws.Cells(i + j, c).Value = Me.Product.Value <---- This is
where i get the error. It will not allow me to use "Product" since it's not
one of the text boxes

Me.Product.ClearContents
Case 2
Product = Product + "_sold"
ws.Cells(i + j, c).Value = Me.Product.Value
Me.Product.ClearContents
End If
Case 3
' Product = Product + "_damage"
' If Not IsEmpty(Me.Product) Then
' ws.Cells(i + j, c).Value = Me.Product.Value
' Me.Product.ClearContents
' End If
End Select
Next i
Next j
Else
Response = MsgBox("You Did Not Enter The Mall / Date, Please Enter
Again", vbExclamation, "Missing Information")
End If
End Sub

Help Thanks

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
Compile error: Ambigious name detected: Worksheet_Change **NEWBIE** dan Excel Discussion (Misc queries) 1 May 26th 06 10:13 AM
compile error message on a new excel workbook opening manicmollymacomb Excel Discussion (Misc queries) 0 March 3rd 06 10:06 PM
Compile Error in Excel 2004 when Inputbox contains "VBCRLF" QTP Professional Excel Discussion (Misc queries) 1 November 18th 05 11:47 PM
Compile error in hidden module arjay Excel Discussion (Misc queries) 5 September 16th 05 12:47 AM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 02:54 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"