Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Replacement Code for Excel 97 Users - Join function


The code below works fine for users on excel 2003 and later but we have a
couple of people still on 97 which doesn't seem to handle the Join function.
Any thoughts on a replacement code that will work across all versions would
be appreciated. Thanks

Sub DataError()
Dim Contents As String
Contents = Join(WorksheetFunction.Transpose(Range("L2:L1250") ), Chr(1))
If InStr(1, Contents, Chr(1) & "Not on System" & Chr(1), vbTextCompare) Then
MsgBox "Please review and update the database if required."
End If
Application.ScreenUpdating = True
End Sub
Application.ScreenUpdating = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Replacement Code for Excel 97 Users - Join function


It looks like you are just seeing if any of the cells in L2:L1250 contain
"Not in System". You could do that with the Find command:

Sub DataError()
Dim c As Range
With ActiveSheet.Range("L2:L1250")
Set c = .Find("Not on System", LookIn:=xlValues)
If Not c Is Nothing Then
MsgBox "Please review and update the database if required."
End If
End With
End Sub

I don't have access to Excel 97 any more, but hopefully it supports Find.

Hope this helps,

Hutch

"Monk" wrote:

The code below works fine for users on excel 2003 and later but we have a
couple of people still on 97 which doesn't seem to handle the Join function.
Any thoughts on a replacement code that will work across all versions would
be appreciated. Thanks

Sub DataError()
Dim Contents As String
Contents = Join(WorksheetFunction.Transpose(Range("L2:L1250") ), Chr(1))
If InStr(1, Contents, Chr(1) & "Not on System" & Chr(1), vbTextCompare) Then
MsgBox "Please review and update the database if required."
End If
Application.ScreenUpdating = True
End Sub
Application.ScreenUpdating = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Replacement Code for Excel 97 Users - Join function


The Join function (which takes a one-dimensional array of string values and
makes them into a single string of text, separating each array element in
that string using a specified delimiter) was added to the VBA language
starting in VB6. For versions of Excel using an earlier version of VB, you
will need to loop through the array, one element at a time, and concatenate
the string of text as you go. I don't have access to XL97, so I can't test
this, but I expect it would work. Replace this line...

Contents = Join(WorksheetFunction.Transpose(Range("L2:L1250") ), Chr(1))

with these lines...

Dim Elements() As Variant

Elements = WorksheetFunction.Transpose(Range("L2:L1250"))
For X = LBound(Elements) To UBound(Elements)
If X < UBound(Elements) Then Contents = Contents & Chr(1)
Contents = Contents & Elements(X)
Next

putting the Dim statement up with your other Dim statements.

--
Rick (MVP - Excel)


"Monk" wrote in message
...
The code below works fine for users on excel 2003 and later but we have a
couple of people still on 97 which doesn't seem to handle the Join
function.
Any thoughts on a replacement code that will work across all versions
would
be appreciated. Thanks

Sub DataError()
Dim Contents As String
Contents = Join(WorksheetFunction.Transpose(Range("L2:L1250") ), Chr(1))
If InStr(1, Contents, Chr(1) & "Not on System" & Chr(1), vbTextCompare)
Then
MsgBox "Please review and update the database if required."
End If
Application.ScreenUpdating = True
End Sub
Application.ScreenUpdating = True
End Sub


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
Code replacement RZ[_2_] Excel Programming 2 December 28th 07 05:07 PM
PPMT function replacement Huskerpaulie Excel Worksheet Functions 1 November 26th 07 09:40 PM
replacement for IF function? fastballfreddy Excel Discussion (Misc queries) 7 May 8th 06 04:56 PM
In Excel VBA Editor, how do I hide my code from other users? Mayberrk Excel Discussion (Misc queries) 1 February 8th 05 06:11 AM


All times are GMT +1. The time now is 05:33 AM.

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"