Solved

check range with Excel VBA

Posted on 2015-01-06
4
210 Views
Last Modified: 2015-01-06
How can I use VBA dynamically determine the code. The number of rows may change, eg D20, D31...

Sheet1.Range("A2:D15")
0
Comment
Question by:AXISHK
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 40533371
Hi,

pls try

Sheet1.Range(Range("A2"), Range("D" & Cells.Rows.Count).End(xlUp))


Regards
0
 
LVL 18

Assisted Solution

by:Simon
Simon earned 200 total points
ID: 40533375
Or use this if you only want the contiguous block of cells starting from A2:
Dim rng As Range
Set rng = Range(Cells(2, 1), Cells(2, 4).End(xlDown))
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 300 total points
ID: 40533408
Or if the D cell could be empty but not the cell A in last row

Sheet1.Range(Range("A2"), Range("D" & Range("A" & Cells.Rows.Count).End(xlUp).Row))
0
 

Author Closing Comment

by:AXISHK
ID: 40534877
Tks
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 2016 without internet 6 38
Excel Question 17 15
VBA Fill Blanks with text from another cell 6 21
Excel - remove duplicates 1 13
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question