![]() |
type mixturte in ByReference argument
OK I get this error message "type mixturte in ByReference argument". The
code is: Sub chartID(i As Integer) Dim s, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) ......... Public Sub findAndRemoveBlanks(s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range ............ Private Sub hittaRubriker(s, t As String) MsgBox t MsgBox s see the first sub chartID gets an integer i. This sub then defines the strings s and t and then calls first one sub and passes s. then it calls another sub and passes both s and t. There is something wrong here but I dont know where... all subs that are called takes string. please help me. Yours sincerly Fabrizio S |
type mixturte in ByReference argument
Change the first jmacro
Sub chartID(i As Integer) Dim s As String, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... OK I get this error message "type mixturte in ByReference argument". The code is: Sub chartID(i As Integer) Dim s, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) ........ Public Sub findAndRemoveBlanks(s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range ........... Private Sub hittaRubriker(s, t As String) MsgBox t MsgBox s see the first sub chartID gets an integer i. This sub then defines the strings s and t and then calls first one sub and passes s. then it calls another sub and passes both s and t. There is something wrong here but I dont know where... all subs that are called takes string. please help me. Yours sincerly Fabrizio S |
type mixturte in ByReference argument
Great! Thank you very much Mr Philips! However I found out that I might need
to change the code a bit. The problem is that the Sub hittaRubriker(s,t) searches spreadsheet for the cell that contains the info in the strings s and t. However the address of these cells are later required. Is there any way to solve this. Shall I define the strings as objects instead? If so how do I assign values to them. Any assistance that you may provide is always very much appreciated. Code: Private Sub hittaRubriker(s, t As String) Dim rng1, rng2, rng3 As Range Set rng1 = Worksheets(s).Cells.Find(t, LookIn:=xlValues) Call chartMaker(s, t) End Sub Sub chartMaker(s, t As String) i = 1 Do Until IsEmpty(t.Offset(i, 0)) = True Or t.Offset(i, 0).Text = strStartDatumArray(1) = True i = i + 1 Loop ...... End Sub "Bob Phillips" skrev: Change the first jmacro Sub chartID(i As Integer) Dim s As String, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... OK I get this error message "type mixturte in ByReference argument". The code is: Sub chartID(i As Integer) Dim s, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) ........ Public Sub findAndRemoveBlanks(s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range ........... Private Sub hittaRubriker(s, t As String) MsgBox t MsgBox s see the first sub chartID gets an integer i. This sub then defines the strings s and t and then calls first one sub and passes s. then it calls another sub and passes both s and t. There is something wrong here but I dont know where... all subs that are called takes string. please help me. Yours sincerly Fabrizio S |
type mixturte in ByReference argument
What I would do is change the hittaRubriker sub to a function that returns
the cell found as a range object, and use that throughout. Here is an example Sub chartID(i As Integer) Dim s As String, t As String Dim foundCell As Range If i = 0 Then s = "Mod Dur" t = "test" End If Call findAndRemoveBlanks(s) Set foundCell = hittaRubriker(s, t) If Not foundCell Is Nothing Then MsgBox "chartID: " & foundCell.Address End If End Sub Public Sub findAndRemoveBlanks(ByRef s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range End Sub Private Function hittaRubriker(ByVal s As String, _ ByVal t As String) As Range Set hittaRubriker = ActiveSheet.Cells.Find(s & t) If Not hittaRubriker Is Nothing Then MsgBox "hittaRubriker: " & hittaRubriker.Address End If End Function -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... Great! Thank you very much Mr Philips! However I found out that I might need to change the code a bit. The problem is that the Sub hittaRubriker(s,t) searches spreadsheet for the cell that contains the info in the strings s and t. However the address of these cells are later required. Is there any way to solve this. Shall I define the strings as objects instead? If so how do I assign values to them. Any assistance that you may provide is always very much appreciated. Code: Private Sub hittaRubriker(s, t As String) Dim rng1, rng2, rng3 As Range Set rng1 = Worksheets(s).Cells.Find(t, LookIn:=xlValues) Call chartMaker(s, t) End Sub Sub chartMaker(s, t As String) i = 1 Do Until IsEmpty(t.Offset(i, 0)) = True Or t.Offset(i, 0).Text = strStartDatumArray(1) = True i = i + 1 Loop ..... End Sub "Bob Phillips" skrev: Change the first jmacro Sub chartID(i As Integer) Dim s As String, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... OK I get this error message "type mixturte in ByReference argument". The code is: Sub chartID(i As Integer) Dim s, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) ........ Public Sub findAndRemoveBlanks(s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range ........... Private Sub hittaRubriker(s, t As String) MsgBox t MsgBox s see the first sub chartID gets an integer i. This sub then defines the strings s and t and then calls first one sub and passes s. then it calls another sub and passes both s and t. There is something wrong here but I dont know where... all subs that are called takes string. please help me. Yours sincerly Fabrizio S |
type mixturte in ByReference argument
Yes, thank you!! That code works just fine!! However I managed to get another
problem..The problem (that perhaps is quite easy if you know it.) is that I use the Sub chartID to call to other subs to which I submit variabels. In these cases it is no problem. But when I call: Private Sub hittaRubriker(s, t, u, v As String) I want to be able to send rng1, rng2, rng3 to the Sub chartMarker, and this is no problem. However I also want to send the variable s that is a string (rng are Range). My code for this is: Call chartMaker(rng1, rng2, rng3, s) and in chartMarKer: Sub chartMaker(rng1, rng2, rng3 As Range, ByRef s As String) This is obviously wrong but I do not know what the problem is nor how to fix it. If you have any idea please help me. As always your assistance is appreciated wholehartedly. Sub chartID(index As Integer) Dim s As String, t As String, u As String, v As String If index = 0 Then s = "Indata" t = "Date" u = "MV" v = "QC" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t, u, v) End If If index = 1 Then s = "Mod Dur" t = "Date" u = "MV" v = "QC" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t, u, v) End If End Sub Public Sub findAndRemoveBlanks(s As String) ............ End Sub Private Sub hittaRubriker(s, t, u, v As String) Dim rng1, rng2, rng3 As Range Set rng1 = Worksheets(s).Cells.Find(t, LookIn:=xlValues) Set rng2 = Worksheets(s).Cells.Find(u, LookIn:=xlValues) Set rng3 = Worksheets(s).Cells.Find(v, LookIn:=xlValues) Call chartMaker(rng1, rng2, rng3, s) End Sub Sub chartMaker(rng1, rng2, rng3 As Range, ByRef s As String) Dim i, j As Integer ........ "Bob Phillips" skrev: What I would do is change the hittaRubriker sub to a function that returns the cell found as a range object, and use that throughout. Here is an example Sub chartID(i As Integer) Dim s As String, t As String Dim foundCell As Range If i = 0 Then s = "Mod Dur" t = "test" End If Call findAndRemoveBlanks(s) Set foundCell = hittaRubriker(s, t) If Not foundCell Is Nothing Then MsgBox "chartID: " & foundCell.Address End If End Sub Public Sub findAndRemoveBlanks(ByRef s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range End Sub Private Function hittaRubriker(ByVal s As String, _ ByVal t As String) As Range Set hittaRubriker = ActiveSheet.Cells.Find(s & t) If Not hittaRubriker Is Nothing Then MsgBox "hittaRubriker: " & hittaRubriker.Address End If End Function -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... Great! Thank you very much Mr Philips! However I found out that I might need to change the code a bit. The problem is that the Sub hittaRubriker(s,t) searches spreadsheet for the cell that contains the info in the strings s and t. However the address of these cells are later required. Is there any way to solve this. Shall I define the strings as objects instead? If so how do I assign values to them. Any assistance that you may provide is always very much appreciated. Code: Private Sub hittaRubriker(s, t As String) Dim rng1, rng2, rng3 As Range Set rng1 = Worksheets(s).Cells.Find(t, LookIn:=xlValues) Call chartMaker(s, t) End Sub Sub chartMaker(s, t As String) i = 1 Do Until IsEmpty(t.Offset(i, 0)) = True Or t.Offset(i, 0).Text = strStartDatumArray(1) = True i = i + 1 Loop ..... End Sub "Bob Phillips" skrev: Change the first jmacro Sub chartID(i As Integer) Dim s As String, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... OK I get this error message "type mixturte in ByReference argument". The code is: Sub chartID(i As Integer) Dim s, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) ........ Public Sub findAndRemoveBlanks(s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range ........... Private Sub hittaRubriker(s, t As String) MsgBox t MsgBox s see the first sub chartID gets an integer i. This sub then defines the strings s and t and then calls first one sub and passes s. then it calls another sub and passes both s and t. There is something wrong here but I dont know where... all subs that are called takes string. please help me. Yours sincerly Fabrizio S |
type mixturte in ByReference argument
Not sure I understand, but does this fix it
Sub chartMaker(rng1 As Range, rng2 As Range, rng3 As Range, s As String) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... Yes, thank you!! That code works just fine!! However I managed to get another problem..The problem (that perhaps is quite easy if you know it.) is that I use the Sub chartID to call to other subs to which I submit variabels. In these cases it is no problem. But when I call: Private Sub hittaRubriker(s, t, u, v As String) I want to be able to send rng1, rng2, rng3 to the Sub chartMarker, and this is no problem. However I also want to send the variable s that is a string (rng are Range). My code for this is: Call chartMaker(rng1, rng2, rng3, s) and in chartMarKer: Sub chartMaker(rng1, rng2, rng3 As Range, ByRef s As String) This is obviously wrong but I do not know what the problem is nor how to fix it. If you have any idea please help me. As always your assistance is appreciated wholehartedly. Sub chartID(index As Integer) Dim s As String, t As String, u As String, v As String If index = 0 Then s = "Indata" t = "Date" u = "MV" v = "QC" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t, u, v) End If If index = 1 Then s = "Mod Dur" t = "Date" u = "MV" v = "QC" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t, u, v) End If End Sub Public Sub findAndRemoveBlanks(s As String) ........... End Sub Private Sub hittaRubriker(s, t, u, v As String) Dim rng1, rng2, rng3 As Range Set rng1 = Worksheets(s).Cells.Find(t, LookIn:=xlValues) Set rng2 = Worksheets(s).Cells.Find(u, LookIn:=xlValues) Set rng3 = Worksheets(s).Cells.Find(v, LookIn:=xlValues) Call chartMaker(rng1, rng2, rng3, s) End Sub Sub chartMaker(rng1, rng2, rng3 As Range, ByRef s As String) Dim i, j As Integer ....... "Bob Phillips" skrev: What I would do is change the hittaRubriker sub to a function that returns the cell found as a range object, and use that throughout. Here is an example Sub chartID(i As Integer) Dim s As String, t As String Dim foundCell As Range If i = 0 Then s = "Mod Dur" t = "test" End If Call findAndRemoveBlanks(s) Set foundCell = hittaRubriker(s, t) If Not foundCell Is Nothing Then MsgBox "chartID: " & foundCell.Address End If End Sub Public Sub findAndRemoveBlanks(ByRef s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range End Sub Private Function hittaRubriker(ByVal s As String, _ ByVal t As String) As Range Set hittaRubriker = ActiveSheet.Cells.Find(s & t) If Not hittaRubriker Is Nothing Then MsgBox "hittaRubriker: " & hittaRubriker.Address End If End Function -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... Great! Thank you very much Mr Philips! However I found out that I might need to change the code a bit. The problem is that the Sub hittaRubriker(s,t) searches spreadsheet for the cell that contains the info in the strings s and t. However the address of these cells are later required. Is there any way to solve this. Shall I define the strings as objects instead? If so how do I assign values to them. Any assistance that you may provide is always very much appreciated. Code: Private Sub hittaRubriker(s, t As String) Dim rng1, rng2, rng3 As Range Set rng1 = Worksheets(s).Cells.Find(t, LookIn:=xlValues) Call chartMaker(s, t) End Sub Sub chartMaker(s, t As String) i = 1 Do Until IsEmpty(t.Offset(i, 0)) = True Or t.Offset(i, 0).Text = strStartDatumArray(1) = True i = i + 1 Loop ..... End Sub "Bob Phillips" skrev: Change the first jmacro Sub chartID(i As Integer) Dim s As String, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Fabrizio" wrote in message ... OK I get this error message "type mixturte in ByReference argument". The code is: Sub chartID(i As Integer) Dim s, t As String If i = 0 Then s = "Mod Dur" t= "test" Call findAndRemoveBlanks(s) Call hittaRubriker(s, t) ........ Public Sub findAndRemoveBlanks(s As String) Dim WB As Workbook Dim SH As Worksheet Dim rng, rCell As Range ........... Private Sub hittaRubriker(s, t As String) MsgBox t MsgBox s see the first sub chartID gets an integer i. This sub then defines the strings s and t and then calls first one sub and passes s. then it calls another sub and passes both s and t. There is something wrong here but I dont know where... all subs that are called takes string. please help me. Yours sincerly Fabrizio S |
All times are GMT +1. The time now is 04:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com