Solved

check range with Excel VBA

Posted on 2015-01-06
4
219 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 51

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 51

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

705 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