Solved

VBA to select range of cells from A2 to ........

Posted on 2013-12-10
10
345 Views
Last Modified: 2013-12-10
Can an Expert provide me with the VBA code I need to select a range of cells from A2 but where the end cell could change so it could be AM500 or AT1000 etc etc

Thanks
0
Comment
Question by:Jagwarman
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39708549
a row based selection might look like this:
Range(Selection, Selection.End(xlToRight)).Select

Open in new window

whereas "Selection" could be "Range("A2")"
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39708565
Range(Range("A2"), Cells.Find("*", Range("A1"), , , , xlPrevious)).Select
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 39708790
Assuming continuous data in at least one row and one column:

Range("A2").Select
CurrentRegion.Select


CurrentRegion.Select is equivalent to keyboard selection of "Ctrl + *"

Thanks
Rob H
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:Jagwarman
ID: 39708875
Rob H

Unfortunately there are some columns with nothing in them so this does not work on my current file.
0
 

Author Comment

by:Jagwarman
ID: 39708883
ssaqibh

this a,most works but for some reason it goes to AK but there is data in AL which it is not capturing ???
0
 

Author Comment

by:Jagwarman
ID: 39708952
Alex140181 this does not work for me because there are blank rows in between. but thanks for trying
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 39709075
Do the empty columns have a header? If they do then it should still work as the header row is constant. If not, hence why the EndRight suggestion doesn't work.

Would inserting just a # or just a space in the relevant columns be a workaround; just to populate these columns so that the columns beyond these get included in current region?

If populated the EndRight would also then work.

Thanks
Rob H
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39709082
Then try

Range(Range("A2"), Cells.SpecialCells(xlCellTypeLastCell)).Select
0
 

Author Comment

by:Jagwarman
ID: 39709105
Rob H

I do use that in other circumstances but it won't work in this one but thanks for trying.
0
 

Author Closing Comment

by:Jagwarman
ID: 39709109
Exactly what I was looking for. Thanks
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
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…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

823 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