Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2024, 08:48 AM
SARCux's Avatar
SARCux SARCux is offline Problem with VBA Code Windows 11 Problem with VBA Code Office 2021
Novice
Problem with VBA Code
 
Join Date: Nov 2024
Location: Germany
Posts: 1
SARCux is on a distinguished road
Exclamation Problem with VBA Code

Hi @all,



I have the same version of Excel on both PCs.
The following is not running on one workstation:

Code:
Set rngDate = Cells.Find(What:=Date, LookAt:=xlWhole, LookIn:=xlValues)
complete code
Code:
Sub Zum_aktuellen_Datum_scrollen()
    Dim rngDate As Range
   
    Set rngDate = Cells.Find(What:=Date, LookAt:=xlWhole, LookIn:=xlValues)
   
    If rngDate Is Nothing = False Then
'
'        'Zur Zelle, mit dem aktuellen Datum scrollen, Row / Column
'        Application.Goto Reference:=rngDate, scroll:=True
'
        'Zur Zeile, mit dem aktuellen Datum scrollen.
        ActiveWindow.ScrollRow = rngDate.Row
'
'        'Zur Spalte, mit dem aktuellen Datum scrollen.
'        ActiveWindow.ScrollColumn = rngDate.Column

    End If
   
End Sub
Can someone explain to me what the error is here?
Reply With Quote
  #2  
Old 11-09-2024, 11:06 AM
NoSparks NoSparks is offline Problem with VBA Code Windows 10 Problem with VBA Code Office 2010
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

I'm guessing a difference in Windows regional settings of dates and the way Excel is displaying them on the sheet.
Code:
Sub Scroll_to_current_date()

    Dim rngDate As Range

MsgBox Date & vbLf & vbLf & _
       "This is just to see what Windows has for Date format" & vbLf & _
       "if this differs from the sheet date formats" & vbLf & _
       "try changing LookIn:=xlValues to LookIn:=xlFormulas"

Set rngDate = Cells.Find(What:=Date, LookAt:=xlWhole, LookIn:=xlValues)

If Not rngDate Is Nothing Then
    '
    ' 'Scroll to the cell with the current date, Row / Column
    ' Application.Goto Reference:=rngDate, scroll:=True
    '
    'Scroll to the row with the current date.
    ActiveWindow.ScrollRow = rngDate.Row
    '
    ' 'Scroll to the column with the current date.
    ' ActiveWindow.ScrollColumn = rngDate.Column
End If

End Sub

Last edited by NoSparks; 11-09-2024 at 11:44 AM. Reason: included a sub that might help
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with VBA Code Convert a word VBA code to PowerPoint VBA code laith93 Word VBA 5 11-09-2023 08:40 AM
Problem with VBA Code Problem with ZIP code serial printing Kuzcomerlin Mail Merge 3 01-22-2020 02:12 PM
Problem with VBA Code Problem with currency field code DIYman Mail Merge 2 09-22-2015 12:16 AM
Problem with VBA Code Start of Document Code Problem norgro Word VBA 2 02-12-2013 04:03 AM
Custom formatting code - rounding problem venkys4u Excel 1 08-14-2012 07:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft