Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Find area, select and copy

Posted on 2011-09-07
4
Medium Priority
?
214 Views
Last Modified: 2012-05-12
Hi,

I need a piece of code that can select the area of the attached spreadsheet.

I canT use cells select as i can copy exactly the area ("A1:W52")

This area will change each day though so i need the code to loop through A, find the first blank cell, then move across to W on the same row and back up to the top

Ao it will always be Columne "A:W" but the rows will vary

Thanks
Seamus


test.xls
0
Comment
Question by:Seamus2626
4 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 2000 total points
ID: 36494592
Assuming you always have data, I think this should work:

Range("A1", Range("A1").End(xlDown)).Resize(, 23).Select
0
 

Author Closing Comment

by:Seamus2626
ID: 36494616
Spot on, cheers Stephen

Seamus
0
 
LVL 34

Expert Comment

by:Rob Henson
ID: 36494634
Does selecting Current Region work for you?

Before coding it, select A1 and then press "Ctrl + *" or "Ctrl + Shift + 8" (keypad 8 as opposed to number pad 8, shift + 8 being *).

Does this select the right area?

For code this would be:

Range("A1").Select
CurrentRegion.Select

Open in new window


Alternatiely create a dynamic Named Range using OFFSET to define the area then the code can select the named area.

=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),23)

Thanks
Rob H
0
 
LVL 31

Expert Comment

by:gowflow
ID: 36494655
for you in the attached sheet what is the area that need to be selected ? A1:W52 ? if yes then try the following file
Press on the command button Select A:W and check the results. You need to enable macros
gowflow
test.xls
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

926 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