ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set current cell to a specific value (https://www.excelbanter.com/excel-programming/392031-set-current-cell-specific-value.html)

Diogo

Set current cell to a specific value
 
Ok, to put it in simple terms I've a calendar in colum A ranging from cell A1
to A365, In cell B1 i've Today() function.
What I want to do is when I open this excel file I want the active cell in
colum A to be the one that has the corresponding date equal to cell B1. Is
this possibel? Some sort of code? If yes could someone exemplify?
Thanks.

Chip Pearson

Set current cell to a specific value
 
Try somthing like the following:


Dim R As Variant
With ThisWorkbook.Worksheets("Sheet1")
R = Application.Match(.Range("B1"), .Range("A1:A365"), 0)
If IsError(R) = False Then
.Range("A1")(R, 1).Select
End If
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Diogo" wrote in message
...
Ok, to put it in simple terms I've a calendar in colum A ranging from cell
A1
to A365, In cell B1 i've Today() function.
What I want to do is when I open this excel file I want the active cell in
colum A to be the one that has the corresponding date equal to cell B1. Is
this possibel? Some sort of code? If yes could someone exemplify?
Thanks.



Ken

Set current cell to a specific value
 
Try this code in the Workbook_Open event

Private Sub Workbook_Open()

Cells(Application.Match((CDbl(Range("b1").Value)), Range("a:a")),
1).Activate

End Sub

Good luck.

Ken
Norfolk, Va


On Jun 25, 4:20 pm, Diogo wrote:
Ok, to put it in simple terms I've a calendar in colum A ranging from cell A1
to A365, In cell B1 i've Today() function.
What I want to do is when I open this excel file I want the active cell in
colum A to be the one that has the corresponding date equal to cell B1. Is
this possibel? Some sort of code? If yes could someone exemplify?
Thanks.





All times are GMT +1. The time now is 03:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com