Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Combine macros mismatch

I try combining the 2 macros below into 1 in the same sheet, the codes shown.
But I was prompted error below---
Run-time error '13':Type mismatch

Sub CallMacros()
Call ButtonReset_Click
Call Worksheet_Calculate
End Sub


Private Sub Worksheet_Calculate()
Dim r As Range
Set r = Range("E65")
If r = "pop" Then Msg = MsgBox("Joint capacity is insufficient.Re-select a
bigger section size.", vbExclamation + vbOKOnly, "Rectangular Hollow Section")

End Sub

Sub ButtonReset_Click()
If MsgBox("Are you sure you want to permanently delete the data?", _
vbQuestion + vbYesNo + vbDefaultButton, "Rectangular Hollow Section") = vbNo
Then Exit Sub
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 20 Then
cell.Formula = ""
End If
Next cell
End Sub


Appreciate any help on where I went wrong. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combine macros mismatch


You have not said on what command you are getting the error message
Assuming error in in the CallMacros macro try using the following
commands
Change book & shhet names to suit


Code:
--------------------

Application.Run "Book1.xls!Sheet1.ButtonReset_Click"
Application.Run "Book1.xls!Sheet1.Worksheet_Calculate"

--------------------


--
mudraker

If my reply has assisted or failed to assist you I welcome your
Feedback.

www.thecodecage.com
------------------------------------------------------------------------
mudraker's Profile: http://www.thecodecage.com/forumz/member.php?userid=18
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=64570

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Combine macros mismatch

I think I would do it like this. If I wanted the worksheet_calculate to
checkr then just call it from there.

Sub combineem()
Call ButtonReset_Click
Call checkr
End Sub

Sub ButtonReset_Click()
If MsgBox("Are you sure you want to permanently delete the data?", _
vbQuestion + vbYesNo + vbDefaultButton, "Rectangular Hollow Section") _
= vbNo Then Exit Sub

For Each c In ActiveSheet.UsedRange
If c.Interior.ColorIndex = 20 Then
c.ClearContents
End If
Next c
End Sub

Sub checkr()
Dim r As Range
Set r = Range("b1")
If lcase(r) = "pop" Then _
MsgBox "Joint capacity is insufficient.Re-select a bigger section size.", _
vbExclamation + vbOKOnly, "Rectangular Hollow Section"
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"amelia" wrote in message
...
I try combining the 2 macros below into 1 in the same sheet, the codes
shown.
But I was prompted error below---
Run-time error '13':Type mismatch

Sub CallMacros()
Call ButtonReset_Click
Call Worksheet_Calculate
End Sub


Private Sub Worksheet_Calculate()
Dim r As Range
Set r = Range("E65")
If r = "pop" Then Msg = MsgBox("Joint capacity is insufficient.Re-select a
bigger section size.", vbExclamation + vbOKOnly, "Rectangular Hollow
Section")

End Sub

Sub ButtonReset_Click()
If MsgBox("Are you sure you want to permanently delete the data?", _
vbQuestion + vbYesNo + vbDefaultButton, "Rectangular Hollow Section") =
vbNo
Then Exit Sub
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 20 Then
cell.Formula = ""
End If
Next cell
End Sub


Appreciate any help on where I went wrong. Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Combine macros mismatch

Ive tried like you suggested--Sub checkr().
But the message box doesn't appear when cell E65="pop" and was prompted a
mismatch error. Cell E65 is dependent on some other cells that caused E65 to
change to "pop".

My previous code..
I was also prompted a mismatch error and this is highlighted--If r = "pop"
Then.

Appreciate any help..

"Don Guillett" wrote:

I think I would do it like this. If I wanted the worksheet_calculate to
checkr then just call it from there.

Sub combineem()
Call ButtonReset_Click
Call checkr
End Sub

Sub ButtonReset_Click()
If MsgBox("Are you sure you want to permanently delete the data?", _
vbQuestion + vbYesNo + vbDefaultButton, "Rectangular Hollow Section") _
= vbNo Then Exit Sub

For Each c In ActiveSheet.UsedRange
If c.Interior.ColorIndex = 20 Then
c.ClearContents
End If
Next c
End Sub

Sub checkr()
Dim r As Range
Set r = Range("b1")
If lcase(r) = "pop" Then _
MsgBox "Joint capacity is insufficient.Re-select a bigger section size.", _
vbExclamation + vbOKOnly, "Rectangular Hollow Section"
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"amelia" wrote in message
...
I try combining the 2 macros below into 1 in the same sheet, the codes
shown.
But I was prompted error below---
Run-time error '13':Type mismatch

Sub CallMacros()
Call ButtonReset_Click
Call Worksheet_Calculate
End Sub


Private Sub Worksheet_Calculate()
Dim r As Range
Set r = Range("E65")
If r = "pop" Then Msg = MsgBox("Joint capacity is insufficient.Re-select a
bigger section size.", vbExclamation + vbOKOnly, "Rectangular Hollow
Section")

End Sub

Sub ButtonReset_Click()
If MsgBox("Are you sure you want to permanently delete the data?", _
vbQuestion + vbYesNo + vbDefaultButton, "Rectangular Hollow Section") =
vbNo
Then Exit Sub
For Each cell In ActiveSheet.UsedRange
If cell.Interior.ColorIndex = 20 Then
cell.Formula = ""
End If
Next cell
End Sub


Appreciate any help on where I went wrong. 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
combine two macros puiuluipui Excel Discussion (Misc queries) 4 May 21st 09 10:30 AM
COMBINE TWO MACROS INTO ONE K[_2_] Excel Programming 10 January 4th 08 01:48 PM
Combine 2 macros into 1 Please. Steved Excel Programming 3 May 24th 07 06:29 PM
combine two macros Lisa Excel Worksheet Functions 1 July 20th 06 02:10 AM
Combine 2 Macros al007 Excel Programming 1 December 29th 05 04:57 PM


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