VBA conditional selection of ranges in table

zeno

Board Regular
Joined
Feb 16, 2012
Messages
71
[h=2][/h]
Hi,

I have an Excel table with different dates, times, etc. This table can be divided into 3 ranges or arrays, based on column 'C'.

'A' --- 'B' --- 'C'
date - time - 1
date - time - 1
date - time - 2
date - time - 3
date - time - 3
date - time - 3
etc.

I'd like to know how in <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; ">VBA</acronym> I can define the 3 different ranges (or arrays) for a variable number of rows. Every range would contain the 3 columns.

Thank you for your help.​
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I see that I can define the whole table as range with the following code:

Code:
Set rng=Range("A2:C" & end_row)

But I would have to compare between the 3 different ranges. So how can I find the last row of '1' in column 'C', the rows of '2' and those of '3'?
 
Upvote 0
I'm trying with the following code, which does not work. I thought that the value of 'D2' would be taken, but instead it is copying the whole table?

Code:
Sheets("Sheet1").Range("A2:J" & Range("D2").End(xlDown).Row).Copy _
   Destination:=Sheets("Sheet2").Range("A2")
 
Upvote 0
I'm looking into a 'Range.Group' method, but this seems to be possible if the object is a single cell? Possibly multiple-area ranges could work.
Thank you for any suggestions.
 
Upvote 0

Forum statistics

Threads
1,216,113
Messages
6,128,905
Members
449,478
Latest member
Davenil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top