Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default pass cell value as string to function

I am looping through a range of cells and want to pass a the value to
another function as a string. Actually, it doesn't have to be a string,
I just am not sure how to pass it. I made test1 a string and then made
the value of test1 = the value of the cell then tried to pass as a string
but I get a ByReg argument type missmatch error. What concept am I
missing here?

Sub Looper()

Dim ColA As Range
Dim ColB As Range
Dim counter As Long
Dim rowNumber As Integer
Dim cellNumber As Integer
Dim test1, test2, test3 As String

Set ColA = Sheets("Puzzle").Range("A1:P16")
Set ColB = Sheets("Puzzle").Range("R1:AH16")
For rowNumber = 1 To 16
'For rowNumber = 1654 To 4086
'Set ColA = Sheets("Puzzle").Range(Cells(rowNumber, 1), Cells
(rowNumber, 16))

For cellNumber = 1 To 16
test1 = ColA.Cells(rowNumber, cellNumber)

If test1 < "" Then

'If ((Cells(rowNumber, 15).Value = "DI" Or Cells
(rowNumber, 15).Value = "DO") _
' And Cells(rowNumber, 23).Value < "N/A") Then
' CreateDigitalDoc ColA, wordDocDigital
'ElseIf (Cells(rowNumber, 23).Value < "N/A") Then
' CreateAnalogDoc ColA, wordDocAnalog
'End If
'Next cellNumber
ColB.Cells(rowNumber, cellNumber) = ColA.Cells
(rowNumber, cellNumber)
test2 = CStr(test1)
UpdateAll rowNumber, cellNumber, test2
End If
Next cellNumber
Next rowNumber

End Sub

Sub UpdateAll(rowNumber As Integer, cellNumber As Integer, test2 As
String)
'do some stuff here
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default pass cell value as string to function

When you declare variables like this:
Dim test1, test2, test3 As String
only test3 is declared as a String. test1 and test2 will be assigned the
DataType Variant. UpdateAll is looking for a variable with a string
datatype.

Change your decleration to
dim test1 as string, test2 as string, test3 as string

or
Dim test1 as string
dim test2 as string
dim test3 as string

Hope this helps
Rowan

fybar wrote:
I am looping through a range of cells and want to pass a the value to
another function as a string. Actually, it doesn't have to be a string,
I just am not sure how to pass it. I made test1 a string and then made
the value of test1 = the value of the cell then tried to pass as a string
but I get a ByReg argument type missmatch error. What concept am I
missing here?

Sub Looper()

Dim ColA As Range
Dim ColB As Range
Dim counter As Long
Dim rowNumber As Integer
Dim cellNumber As Integer
Dim test1, test2, test3 As String

Set ColA = Sheets("Puzzle").Range("A1:P16")
Set ColB = Sheets("Puzzle").Range("R1:AH16")
For rowNumber = 1 To 16
'For rowNumber = 1654 To 4086
'Set ColA = Sheets("Puzzle").Range(Cells(rowNumber, 1), Cells
(rowNumber, 16))

For cellNumber = 1 To 16
test1 = ColA.Cells(rowNumber, cellNumber)

If test1 < "" Then

'If ((Cells(rowNumber, 15).Value = "DI" Or Cells
(rowNumber, 15).Value = "DO") _
' And Cells(rowNumber, 23).Value < "N/A") Then
' CreateDigitalDoc ColA, wordDocDigital
'ElseIf (Cells(rowNumber, 23).Value < "N/A") Then
' CreateAnalogDoc ColA, wordDocAnalog
'End If
'Next cellNumber
ColB.Cells(rowNumber, cellNumber) = ColA.Cells
(rowNumber, cellNumber)
test2 = CStr(test1)
UpdateAll rowNumber, cellNumber, test2
End If
Next cellNumber
Next rowNumber

End Sub

Sub UpdateAll(rowNumber As Integer, cellNumber As Integer, test2 As
String)
'do some stuff here
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default pass cell value as string to function

Rowan Drummond wrote in
:

When you declare variables like this:
Dim test1, test2, test3 As String
only test3 is declared as a String. test1 and test2 will be assigned
the DataType Variant. UpdateAll is looking for a variable with a
string datatype.

Change your decleration to
dim test1 as string, test2 as string, test3 as string

or
Dim test1 as string
dim test2 as string
dim test3 as string

Hope this helps
Rowan


Gah! Yes, that helps.

fyb
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
Pass string value to another form yangyh[_5_] Excel Programming 1 September 11th 05 10:01 AM
Pass multiple characters to a string variable ExcelMonkey Excel Programming 5 July 19th 05 11:26 AM
TypeLib Information Problem? Pass a Function's parameter names as string for parsing? Ali G Excel Programming 1 December 3rd 04 07:02 PM
Pass string as Parameter in OpenText method No Name Excel Programming 0 January 8th 04 06:22 AM
Can we Pass String to FieldInfo Array to OpenText Method. Niraj Kumar Singh Excel Programming 0 January 8th 04 05:35 AM


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