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

vba row function

ResolvedVersion 2003

Tony has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course
Access Intermediate course
Access Advanced course

VBA Row Function

How do you delete rows using a variable.
Rows("1:5").delete
works but how do you use a variable name

RE: VBA Row Function

Hi Tony

Thanks for your question

The following code prompts the user to enter a start and finish row and then cocatenates them into a string that is used in the delete method

Sub RowDeleter()

Dim intStart As Integer
Dim intFinish As Integer
Dim strDelete As String

intStart = InputBox("Enter Start Row")
intFinish = InputBox("Enter Finish Row")

strDelete = intStart & ":" & intFinish

Rows(strDelete).Delete

End Sub


Regards

Stephen

 

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:

Changing Excel file and worksheet defaults

The appearance of any new Excel files or any new worksheets that are inserted into a file are controlled by two template files, Book.xlt and Sheet.xlt.

By opening, modifying and saving these templates you can change the default settings for all new files and/or all newly inserted sheets.

Use Book.xlt to make change to defaults for new workbooks; and Sheet.xlt to change defaults for sheets.

If you can't find either of these files on your computer, you can create and save them yourself.

You can do this simply by creating a new workbook with the setting you want to use as your defaults; then saving them with the appropriate name in the XLStart folder. If you are using Office 2003, this is usually found in C:\Program Files\Microsoft Office\Office11\XLStart.

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.09 secs.