Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Using 2 OS (Win98 & Winxp)


Hi Guys can you help me regarding this problem I have a excel vba macr
but when itried to run in different operating system my function won'
change
here's my code:

Private Sub holidate(xhdate As Date) ' to compute if date entered i
Holiday

Dim crowval As Byte

With Worksheets("Sheet2").Range("A1:A30")
Set Holivalue = .Find(xhdate, LookIn:=xlValues, MatchCase:=False)

' .FIND METHOD WON'T WORK IN WINDOWS 98 OS I DON'T KNOW WHY?

If Not Holivalue Is Nothing Then
If Holivalue = xhdate Then
xholid = True
crowval = Holivalue.Row
xcomval = Worksheets("Sheet2").Cells(crowval, 2)
End If
Else
xholid = False
End If

End With
End Sub

Hope you help me guys regarding this eerie problem Thanks :

--
Cybe
-----------------------------------------------------------------------
Cyber's Profile: http://www.excelforum.com/member.php...fo&userid=1580
View this thread: http://www.excelforum.com/showthread.php?threadid=27305

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default VBA Using 2 OS (Win98 & Winxp)

Hi Cyber,

Set Holivalue = .Find(xhdate, LookIn:=xlValues, MatchCase:=False)

' .FIND METHOD WON'T WORK IN WINDOWS 98 OS I DON'T KNOW WHY?


Remove the MatchCase parameter, as this is more likely to be an Excel
version issue than a Windows one.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VBA Using 2 OS (Win98 & Winxp)

I've had lots of trouble with .find with dates. I don't suspect that it's a
windows difference, though.

One thing about using .find in code. I think you'd be better served by
specifying all the parms--Find remembers the last parms that were used--either
via code or through the user interface.

And if you were calling this subroutine from a Function that was placed in a
worksheet cell, then .find won't work for this until xl2002.

But this version (using application.match() and clng()) worked ok for me:

Option Explicit
Dim xHolid As Boolean
Dim xComVal As Variant
Private Sub holidate(xhdate As Date)
Dim res As Variant
With Worksheets("Sheet2").Range("A1:A30")
res = Application.Match(CLng(xhdate), .Cells, 0)
If IsNumeric(res) Then
xHolid = True
xComVal = .Cells(res).Offset(0, 1)
Else
xHolid = False
End If
End With
End Sub
Sub testme()
Call holidate(DateSerial(2004, 10, 31))
MsgBox xHolid & "--" & xComVal
End Sub


Cyber wrote:

Hi Guys can you help me regarding this problem I have a excel vba macro
but when itried to run in different operating system my function won't
change
here's my code:

Private Sub holidate(xhdate As Date) ' to compute if date entered is
Holiday

Dim crowval As Byte

With Worksheets("Sheet2").Range("A1:A30")
Set Holivalue = .Find(xhdate, LookIn:=xlValues, MatchCase:=False)

' .FIND METHOD WON'T WORK IN WINDOWS 98 OS I DON'T KNOW WHY?

If Not Holivalue Is Nothing Then
If Holivalue = xhdate Then
xholid = True
crowval = Holivalue.Row
xcomval = Worksheets("Sheet2").Cells(crowval, 2)
End If
Else
xholid = False
End If

End With
End Sub

Hope you help me guys regarding this eerie problem Thanks :(

--
Cyber
------------------------------------------------------------------------
Cyber's Profile: http://www.excelforum.com/member.php...o&userid=15807
View this thread: http://www.excelforum.com/showthread...hreadid=273059


--

Dave Peterson

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
Excel and Win98 MEL Excel Discussion (Misc queries) 1 June 22nd 09 05:20 PM
Pasting differences with win98 and winxp Graham Excel Discussion (Misc queries) 2 September 4th 06 07:57 AM
xyScatterChart macro works on WinXP Pro & not on WinXP Home? [email protected] Excel Discussion (Misc queries) 0 July 18th 05 12:30 AM
VB and Excel in win98 Patrick[_5_] Excel Programming 1 October 31st 03 09:01 PM
Excel add-in and Win98 Vasek Excel Programming 2 September 28th 03 09:09 AM


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