560 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Selecting Cells using Excel VBA Macros - Absolute Part one of a four-part series of blogs |
---|
This blog gives the various possible ways to select cells, ranges, columns and rows using Visual Basic for Applications in Excel. Useful for the VBA newbie, but even gurus might find one or two commands they'd missed!
This blog is part of our Excel macros online tutorial series. For real-world training, book onto our introductory or advanced VBA or Excel courses.
|
Finding myself with a bit of spare time, I thought I'd summarise the various ways to select cells using VBA within Excel.
I've also blogged on how to select cells relative to your starting point.
This entire blog works for Excel versions 2010, 2007, 2003 and older versions. You can try any of the examples contained it by downloading this Excel workbook.
If you're wondering at this stage what I mean by absolute and relative selection, here's an example:
Suppose you have the orange cell selected (Pooh Bear). You want to select Tigger. If you write a macro to:
I've divided the blog up into:
Enjoy!
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
From: | duggie |
When: | 14 Nov 18 at 13:15 |
Something rather puzzling has occured to my worksheet and I'm not to sure why that is the case.
If I set a range to a worksheet, I expected that refering to a cell that is NOT in the range would result in an error but it hasn't.
For example, if I had the values 10 through to 80 in the cells A1 through to D2 and I write:
Dim rng As Range
Set rng = Range("A1:D1")
Debug.Print rng(3)
this returns the value 30, as expected.
However, if I typed:
Debug.Print rng (5)
I get the value of 50!
But I though rng(5) was OUTSIDE of my range, so surely it should return an error?
Thanks
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2023. All Rights Reserved.