MisterProzilla
Active Member
- Joined
- Nov 12, 2015
- Messages
- 264
Hi there,
What I'm trying to achieve seems pretty simple, just can't figure out the syntax.
On a single row, I enter blocks of numbers which represent sessions, in increments of 15 mins per cell. For example, I might have a number 1 in all cells D2:K2, representing a 2-hour long session.
I want to be able to click on a session, click a button and have the start time and end time retrieved for me in VBA. To do this, I think the easiest way would be to search left, from the active cell, for the first cell that isn't a '1', and return the column; then search right for the first non-'1' cell and return the column. From there, I can offset those column numbers to look up the start/end times along the top.
I'm just stuck on how to look for a value that is not 1 (or whatever is in the active cell, which I can find with ActiveCell.Value)
This is as far as I've got with the code:
Where I've entered ??? is where I need to have it look for a value that doesn't match that of the active cell.
Seems like this should be an easy one, just getting lost in translation from head to VBA
Thanks for looking
What I'm trying to achieve seems pretty simple, just can't figure out the syntax.
On a single row, I enter blocks of numbers which represent sessions, in increments of 15 mins per cell. For example, I might have a number 1 in all cells D2:K2, representing a 2-hour long session.
I want to be able to click on a session, click a button and have the start time and end time retrieved for me in VBA. To do this, I think the easiest way would be to search left, from the active cell, for the first cell that isn't a '1', and return the column; then search right for the first non-'1' cell and return the column. From there, I can offset those column numbers to look up the start/end times along the top.
I'm just stuck on how to look for a value that is not 1 (or whatever is in the active cell, which I can find with ActiveCell.Value)
This is as far as I've got with the code:
Code:
Sub find()
Dim findstart As Long
Dim findend as long
findstart = Sheet4.Range(Cells(2,4),Cells(2,ActiveCell.Column)).Find([B]???[/B], searchdirection:=xlPrevious).Column
findend = Sheet4.Range(Cells(2,ActiveCell.Column),Cells(2,48)).Find([B]???[/B], searchdirection:=xlNext).Column
'look for times in those offset columns, etc
End Sub
Where I've entered ??? is where I need to have it look for a value that doesn't match that of the active cell.
Seems like this should be an easy one, just getting lost in translation from head to VBA
Thanks for looking
Last edited: