LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Run Time Error '13' Type mismatch

This code was working fine unit I tried to divide 1 result by another.



I'm getting a Run Time Error '13' Type mismatch on the

Following line

Worksheets("Zone Summary").Cells(5 + c + (1 + (10 * x - 10)), 6) =
Data2/Data



I have tried to use 'Dim 'for the 'Data' but then I get a compile error
saying that it expects an array.



Any suggestions about fixing this up?


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


Sub SummariseProdStats()



'set number of Stages

For x = 1 To 7



Step = "Zone " & x



For c = 1 To 7



'Commodity 1

ReDim Data(0) ' area

Data(0) = 0

ReDim Data1(0) 'production

Data1(0) = 0

ReDim Data2(0) 'value

Data2(0) = 0



numrows = Worksheets("Zones Raw Data").UsedRange.Rows.Count - 8



For r = 1 To numrows



'Where Data you are testing and getting data from

With Worksheets("Zones Raw Data")

Zonerng = .Cells(8 + r, 1) '.Select

CommodArea = .Cells(8 + r, (c * 3) + 1)

CommodProd = .Cells(8 + r, (c * 3) + 2)

CommodValue = .Cells(8 + r, (c * 3) + 3)

End With



'Save Existing Data

ReDim Preserve Data(UBound(Data) + 1)

ReDim Preserve Data1(UBound(Data1) + 1)

ReDim Preserve Data2(UBound(Data2) + 1)





'Check to see if condition true or false

If Step = Zonerng Then

'add up area

Data(UBound(Data)) = CommodArea

Data(0) = Data(0) + CommodArea

'add up prod

Data1(UBound(Data1)) = CommodProd

Data1(0) = Data1(0) + CommodProd



'add up value

Data2(UBound(Data2)) = CommodValue

Data2(0) = Data2(0) + CommodValue





End If



Next r



'Now paste value to where you want them

Worksheets("Zone Summary").Cells(5 + c + (1 + (10 * x - 10)), 3) = Data

Worksheets("Zone Summary").Cells(5 + c + (1 + (10 * x - 10)), 4) = Data1

Worksheets("Zone Summary").Cells(5 + c + (1 + (10 * x - 10)), 5) = Data2

Worksheets("Zone Summary").Cells(5 + c + (1 + (10 * x - 10)), 6) =
Data2/Data



Next c



Next x



End Sub


 
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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
run-time error 13: Type mismatch? Marko Enula Excel Discussion (Misc queries) 2 February 5th 08 01:00 PM
Visual Basic macro run time error(13) type mismatch Paul Excel Discussion (Misc queries) 0 October 25th 05 07:28 AM


All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"