?
Solved

check range with Excel VBA

Posted on 2015-01-06
4
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

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 800 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 52

Accepted Solution

by:
Rgonzo1971 earned 1200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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