Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

define range

ResolvedVersion 2010

Verzhiniya has attended:
Excel VBA Introduction course

Define a range

Hi,

I would like to define range, which will have a variable row. The idea is that I would like to choose a range up to a specific date. Using match function, I can find the row number. However, I don't know how to use this variable number to define different range every time.

Best regards,
Verzhiniya

RE: Define a range

Hi Verzhiniya,

Thank you for the forum question.

You can store the row number in a variable.

RowNumber=worksheetfunction.match("the date","The range",0)

and then you can use the range object.

Range("A" & RowNumber, "D" & RowNumber).

We have variables on our Excel VBA Intermediate course. Variables are very important to create dynamic codes.

I hope this can point you in the right direction.



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Calculate difference between two times

For presenting the result in the standard time format (hours : minutes : seconds . Use the subtraction operator (-) to find the difference between times, and the TEXT function to format the returned value to text in a specific number format.

Hours never exceed 24, minutes never exceed 60, and seconds never exceed 60.

=TEXT(B2-A2,"h")
Hours between two times (4)

=TEXT(B2-A2,"h:mm")
Hours and minutes between two times (4:55)

=TEXT(B2-A2,"h:mm:ss")
Hours and seconds between two times (4:55:00)

Where B2 and A2 must hold the end time and start time respectively formatted as a time format

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.14 secs.