• Latest
  • Trending
  • All
  • News

How To Use The VBA Current Region Method In Excel

October 16, 2017
5 Vital Car Cleaning Tools To Make A Car Look Brand New

How Exterior Detailing Services Can Enhance the Look of Your Vehicle

January 21, 2024

The Ultimate Guide to Rebuilding a Transmission – Everything You Need to Know

December 10, 2023
5 Weekend Travel Tips for Lasting Joy With the Family

Preparing Your RV For Storage – Essential Steps to Take

November 21, 2023

5 Reasons Why Regular Auto Repair Services Are Crucial for Your Vehicle

November 21, 2023
Comparing the Services of Open Vs. Enclosed Car Shipping

Comparing the Services of Open Vs. Enclosed Car Shipping

November 20, 2023
Heavy Vs. Light Duty Towing: Knowing The Kind of Truck You’ll Need

Heavy Vs. Light Duty Towing: Knowing The Kind of Truck You’ll Need

November 11, 2023
6 great reasons why vehicle owners won’t be stranded when calling out a local locksmith

6 great reasons why vehicle owners won’t be stranded when calling out a local locksmith

October 27, 2023
Six Reasons to Buy a Classic Corvette

Six Reasons to Buy a Classic Corvette

October 20, 2023
Top 5 Signs of Alternator Problems

Top 5 Signs of Alternator Problems

October 10, 2023
7 Common Engine Rebuilding Mistakes and How to Avoid Them

The Benefits of Reliable Auto Repair Services You Can Trust

October 9, 2023
Practical Car Interior Gadgets to Upgrade Your Ride

Top Reasons Why Used Cars Are a Better Investment

July 2, 2023

Essentials of Handicap Vehicles

June 20, 2023
  • Guest Posts
  • Advertise
  • Contact
  • Privacy Policy
Saturday, June 28, 2025
  • Login
Tech Featured - Automotive
  • Home
  • Gadgets
  • Automotive News
  • Interesting Topics
No Result
View All Result
Tech Featured - Automotive
No Result
View All Result
Home News

How To Use The VBA Current Region Method In Excel

October 16, 2017
in News
0
79
SHARES
225
VIEWS
Share on FacebookShare on Twitter

Accessing the Current Region is one of the most valuable VBA techniques in Excel. Not only can it select a data set or table, it enables you to access individual cells, rows and columns within the region; making it very useful for new Excel developers:

  • Search an entire table
  • Select multiple columns to use in a chart
  • Define rows and cells for highlighting

An Example Of Selecting The Current Region

The normal syntax for selecting the currentRegion is as follows:


Range(cellAddress).currentRegion.select

While it makes sense to use the first cell of the table as the base for the region, any cell reference within the region can be used. Let’s look at an example of how you can use the current region in real life.

Let’s say we need to search an entire table starting at “A1” for a defined text string:


myText="text to search for"
myRange="a1"
range(myRange).currentRegion.select

for each c in selection
if instr(c,myText) then
' match found
End if
next

Accessing Cells, Rows And Columns Within The Current Region

Because a region covers multiple rows and columns there are a few different techniques to access items within the region:

In a 2 row by 4 column table (2 x 4) you might want to know the address of the last cell in the table, so you can add data to the next row. This code identifies the next cell address for data input by finding the final row and moving to the next cell.


Range(myRange).currentRegion.select
lastRow=selection.rows.count
cellAddress=selection.rows(lastRow).cells(1).address
range(cellAddress).offset(1,0).activate

Similarly, if we wanted to format each row, we’d need to know how many columns were included in the region:


cols=selection.columns.count

And if you had 3 columns and wanted to return the 2nd column to include as a series range in a chart you could use this line of code:


myRange=selection.columns(2).address

In a 3 x 4 table, this would return a value in the form $B$1:$B$4 which coincidentally is the format to include the column in a chart.

It might be useful to think of the Current Region as a collection, and the cells, rows and columns are items in the collection having their own properties. In this way when you need to access the items within the region you can do so intuitively, rather than relying on knowledge of specific properties and methods.

Summary

The Current Region is one the most useful tools for both new and experienced VBA developers. A good understanding of its methods and properties is essential for effective and productive Excel applications.

Tags: ExcelMethodRegionVBA
Share32Tweet20Share8
  • Trending
  • Comments
  • Latest

John Christie Electric Generator – Generates 24 Kilowatts Of Free Electricity

November 21, 2016

How to Use a Magnetic Generator to Get Rid of Your Electricity Bill

November 21, 2016

Buying a Gazebo – How to Install a Gazebo on Grass

June 8, 2017

The Environmental Benefits of Automobile Recycling

0

Automotive Fasteners – A Number of Items Included on the List

0

Drag Racing – The Perfect Launch

0
5 Vital Car Cleaning Tools To Make A Car Look Brand New

How Exterior Detailing Services Can Enhance the Look of Your Vehicle

January 21, 2024

The Ultimate Guide to Rebuilding a Transmission – Everything You Need to Know

December 10, 2023
5 Weekend Travel Tips for Lasting Joy With the Family

Preparing Your RV For Storage – Essential Steps to Take

November 21, 2023
Tech Featured - Automotive

Navigate Site

  • Guest Posts
  • Advertise
  • Contact
  • Privacy Policy

Follow Us

No Result
View All Result
  • Home
  • Gadgets
  • Automotive News
  • Interesting Topics

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In