Mismatch error

Fooku

New Member
Joined
Jun 19, 2008
Messages
5
Hello. I am fairly new to VB programming, and find it rather more difficult than C. Appreciate whoever can help me.

I am making a template for a family owned engineering firm, which calculates winloads on specific products within the city of FT Lauderdale. Everything had been working until I tried to pass a variable to another sub. Here are the two subs:

This sub determines whether a new sheet needs to be created
Code:
Sub CHART_START()
Dim CT, PNC, PN, CT3, C3, R3, NS, S, C As Integer
CT = 0
PN = Cells(5, 2)
C = 6
Do While CT <= PN
PNC = PNC + Cells(CT + 7, C)
COUNT = COUNT + 1
Loop
CT3 = 1
ROW3 = 11
COLUMN3 = 1
NS = 13
S = 5
Do While CT3 <= PNC
    If CT3 > NS Then
        Call NEW_SHEET(ByVal S)
        S = S + 1
        NS = NS + 13
    End If
    Sheets(S).Select
    Cells(R, C) = CT3
    CT3 = CT3 + 1
    R = R + 2
Loop
End Sub

and this sub creates the new sheet

Code:
Sub NEW_SHEET(S As Integer)
    Sheets("BLANK").Select
    Sheets("BLANK").Copy After:=Sheets(S)
    Sheets(S + 1).Select
    Sheets(S + 1).Name = "CHART " & S - 5
End Sub

When I compile the cursor stops and highlights the S in the second line and highlights in yellow the first line. It then gives the "COMPILE ERROR: TYPE MISMATCH" message box

Code:
Sub CHART_START()
 
Call NEW_SHEET(ByVal S)

I would be greatly debted to whoever can help me.
 
jonmo

The syntax for declaring variables in C is this.
Code:
int gallons, liters
Both are integers and there's not a Dim in site.:)

In Pascal you have this.
Code:
var
   WeeklyPay, YearlyPay : Integer;
   Radius, Circumference, Orbit : Real;
   Punctuation, Initial : Char;
   Untaxed : Boolean;

God, those books where I found that out were dusty.:)
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top