PDA

View Full Version : calling sub from module not work



suny100
05-20-2011, 10:35 AM
I had a code which will run from command button click but i need to run it twice on different 2 sheets so i write the code in command area then i write for the other sheet in module then call it on my command area but it's not work correct?

Could anybody tell me why it's not work?

GTO
05-20-2011, 10:42 AM
Hi Suny,

Could you attach a sample workbook? It is hard to understand your question and I think that this would help.

Mark

suny100
05-20-2011, 10:54 AM
Hi Suny,

Could you attach a sample workbook? It is hard to understand your question and I think that this would help.

Mark

thanks for your reply
here is sample workbook
the code work well but the code on module don't work well inspite of they are the same except the sheets number

suny100
05-20-2011, 11:55 AM
thanks for your reply
here is sample workbook
the code work well but the code on module don't work well inspite of they are the same except the sheets number


hi GTO didn't you find what's happening here ?

Benzadeus
05-20-2011, 12:07 PM
I get an error from this line:
Module4.waste
Delete it.

suny100
05-20-2011, 12:15 PM
I get an error from this line:
Module4.waste
Delete it.

what iam trying to do is call the sub waste from module 4 "which contain same code except sheet number is differs than this code" so i can run it on 2 sheets

Benzadeus
05-20-2011, 12:43 PM
So, send the entire workbook to us, because the one you sent there is no modules.

suny100
05-20-2011, 01:08 PM
So, send the entire workbook to us, because the one you sent there is no modules.


i'm sorry
this is the sample workbook contain the module

nepotist
05-20-2011, 01:17 PM
If I understand it right this should fix it
You are calling the sub routine in a wrong way

Replace the line
Module1.waste
in the button click event with

call waste()

Thank should fix it.

suny100
05-20-2011, 01:27 PM
If I understand it right this should fix it
You are calling the sub routine in a wrong way

Replace the line
Module1.waste
in the button click event with

call waste()

Thank should fix it.

Of course it run the sub but it find only the first number on waste sheet , not check the other numbers but it's work well with finished

suny100
05-20-2011, 01:59 PM
Of course it run the sub but it find only the first number on waste sheet , not check the other numbers but it's work well with finished


Is there any idea ????

nepotist
05-20-2011, 02:05 PM
Could explain what is it that you are actually trying to accomplish. I am a bit lost :|

suny100
05-20-2011, 02:13 PM
Could explain what is it that you are actually trying to accomplish. I am a bit lost :|

as you see in the workbook , i have 3 sheets :
1- reservation
2-Finished
3- waste

I want when i click on Check button on reservation sheet , check if the skill card no. is founded in the other 2 sheets.

that all what i try to accomplish

suny100
05-21-2011, 03:07 PM
as you see in the workbook , i have 3 sheets :
1- reservation
2-Finished
3- waste

I want when i click on Check button on reservation sheet , check if the skill card no. is founded in the other 2 sheets.

that all what i try to accomplish


Is there any help here?

Paul_Hossler
05-21-2011, 03:19 PM
You had a sheet called waste and a sub called waste.

The Command button also seemed to have duplcate code

Try these


Private Sub CommandButton9_Click()
Call WasteSub
End Sub



and


Sub WasteSub()
Dim valFIND As Range
Dim iRow As Long
Dim sB As String
For iRow = 2 To 500
If Cells(iRow, "E") = "1" And Cells(iRow, "E") <> "" Then
If Cells(iRow, "B").Value <> "" Then
sB = Cells(iRow, "B").Value
End If
On Error Resume Next
Set valFIND = Sheet4.Cells.Find(sB, LookIn:=xlValues, LookAt:=xlPart)
If valFIND Like "*" & sB Then
Sheet4.Activate
MsgBox "Value " & valFIND & " was waste"
End If
End If
Next iRow
End Sub


Other than these, I have no more ideas

Paul

nepotist
05-23-2011, 09:52 AM
Is there any help here?

Please find the attachment, I have modified the code to check.