Prev: Combo box in user form
Next: Application.UserName
From: Philosophaie on 2 Apr 2010 22:28 Sub This() Dim A,B,C as Double Dim S as String With Sheets("Sheet1") A=.cells(1,1) B=.cells(1,2) C=.cells(1,3) S=.cells(1,4) End With End Sub This worked one time after that a "Type mismatch" error. Tried these solutions but none worked: A=Cdbl(.cells(1,1)) B=Cdbl.cells(1,2)) C=Cdbl(.cells(1,3)) S=Cstr(.cells(1,4)) A=.cells(1,1).Value B=.cells(1,2).Value C=.cells(1,3).Value S=.cells(1,4) Where am I going wrong?
From: ozgrid.com on 2 Apr 2010 22:44 The error suggests that you don't have numbers in your cells and one or more contains text. -- Regards Dave Hawley www.ozgrid.com "Philosophaie" <Philosophaie(a)discussions.microsoft.com> wrote in message news:E126A0EE-B464-44E7-868A-C754E5D75427(a)microsoft.com... > Sub This() > Dim A,B,C as Double > Dim S as String > With Sheets("Sheet1") > A=.cells(1,1) > B=.cells(1,2) > C=.cells(1,3) > S=.cells(1,4) > End With > End Sub > > This worked one time after that a "Type mismatch" error. Tried these > solutions but none worked: > > A=Cdbl(.cells(1,1)) > B=Cdbl.cells(1,2)) > C=Cdbl(.cells(1,3)) > S=Cstr(.cells(1,4)) > > A=.cells(1,1).Value > B=.cells(1,2).Value > C=.cells(1,3).Value > S=.cells(1,4) > > Where am I going wrong?
From: Philosophaie on 2 Apr 2010 22:56 All the cells I have referenced have a number in them.
From: ozgrid.com on 2 Apr 2010 23:24 I can't reproduce the error from your code. But I have to ask, why are you passing a number to a String variable? -- Regards Dave Hawley www.ozgrid.com "Philosophaie" <Philosophaie(a)discussions.microsoft.com> wrote in message news:DBCBA16A-D40F-4BC1-926C-5D0175915B46(a)microsoft.com... > All the cells I have referenced have a number in them.
From: Philosophaie on 2 Apr 2010 23:50
Here is an Excerpt from my code: Private Sub CommandButton1_Click() Dim d,deg(12), min(12), sec(12), DEGt(24, 2) As Double Dim Zodiac(12) As String Dim h, k, cc, jm As Integer Dim constell As String With Sheets("Sheet1") For d = 1 To 2 For h = 1 To 12 deg(h) = (.Cells(h + 4, 3 + 4 * d)) min(h) = (.Cells(h + 4, 4 + 4 * d)) sec(h) = (.Cells(h + 4, 5 + 4 * d)) DEGt(h, dates) = (deg(h)) + (min(h)) / 60 Zodiac(h) = .Cells(h + 4, 2 + 4 * (dates - 1)) Next h Next d End Sub |