D
Doc
I know I am overlooking something small, but I just cant seem to get a
variable (or for that matter the result of a function) from one sub to
another. Thats probably not very clear so I am including the relevant
portions of code....
Sub WhatToDoWithIt(qCell As Range, qColor As Integer)
'On Error Resume Next
Dim AnsWhat As String, ColHeader As String, NumShts As Integer, HeaderRow As
Integer, HdrNumOfColumns As Integer
HeaderRow = GetHdrRow(ActiveSheet)
<<<<<<<<<<<<<<<<<<<<Problem is here, can not get results from function on
this line into this sub
Range(HeaderRow, 1).Select
HdrNumOfColumns = Selection.SpecialCells(xlCellTypeLastCell).Column
ColHeader = qCell.Cells.End(xlUp).Value
NumShts = (ActiveWorkbook.Sheets.Count).
<<<<Irrelevant code deleted>>>>>>>
Function GetHdrRow(Sht As Worksheet) As Integer
Dim WSO As Worksheet, HdrClue As Range, HdrClueList As Range, HdrTrigger As
Object
Dim firstAddress As String, x As Integer, z As Integer
Static HeaderRow As Integer
z = 0
With ActiveSheet.Range("A1:T3")
Set WSO = ThisWorkbook.Sheets("HeaderSearchStrings")
Set HdrClueList =
WSO.Range("RngName,RngAddress,RngCity,RngEmail,RngPhone,RngZip")
For Each HdrClue In HdrClueList
Set HdrTrigger = .Find(what:=HdrClue, LookIn:=xlValues,
lookat:=xlPart, _
searchorder:=xlByRows)
If Not HdrTrigger Is Nothing Then
firstAddress = HdrTrigger.Address
x = HdrTrigger.Row
Do
Set HdrTrigger = .FindNext(HdrTrigger)
If HdrTrigger.Row = x Then
z = z + 1
End If
Loop While Not HdrTrigger Is Nothing And HdrTrigger.Address
<> firstAddress
End If
Next
End With
If z > 5 Then
HeaderRow = x
Else
HeaderRow = InputBox("Please enter the number of the header row",
"HEADER ROW INFORMATION")
End If
End Function
Please help, TIA
variable (or for that matter the result of a function) from one sub to
another. Thats probably not very clear so I am including the relevant
portions of code....
Sub WhatToDoWithIt(qCell As Range, qColor As Integer)
'On Error Resume Next
Dim AnsWhat As String, ColHeader As String, NumShts As Integer, HeaderRow As
Integer, HdrNumOfColumns As Integer
HeaderRow = GetHdrRow(ActiveSheet)
<<<<<<<<<<<<<<<<<<<<Problem is here, can not get results from function on
this line into this sub
Range(HeaderRow, 1).Select
HdrNumOfColumns = Selection.SpecialCells(xlCellTypeLastCell).Column
ColHeader = qCell.Cells.End(xlUp).Value
NumShts = (ActiveWorkbook.Sheets.Count).
<<<<Irrelevant code deleted>>>>>>>
Function GetHdrRow(Sht As Worksheet) As Integer
Dim WSO As Worksheet, HdrClue As Range, HdrClueList As Range, HdrTrigger As
Object
Dim firstAddress As String, x As Integer, z As Integer
Static HeaderRow As Integer
z = 0
With ActiveSheet.Range("A1:T3")
Set WSO = ThisWorkbook.Sheets("HeaderSearchStrings")
Set HdrClueList =
WSO.Range("RngName,RngAddress,RngCity,RngEmail,RngPhone,RngZip")
For Each HdrClue In HdrClueList
Set HdrTrigger = .Find(what:=HdrClue, LookIn:=xlValues,
lookat:=xlPart, _
searchorder:=xlByRows)
If Not HdrTrigger Is Nothing Then
firstAddress = HdrTrigger.Address
x = HdrTrigger.Row
Do
Set HdrTrigger = .FindNext(HdrTrigger)
If HdrTrigger.Row = x Then
z = z + 1
End If
Loop While Not HdrTrigger Is Nothing And HdrTrigger.Address
<> firstAddress
End If
Next
End With
If z > 5 Then
HeaderRow = x
Else
HeaderRow = InputBox("Please enter the number of the header row",
"HEADER ROW INFORMATION")
End If
End Function
Please help, TIA