range determination

flamme20

New Member
Joined
Apr 27, 2011
Messages
31
There's a macro in my workbook, here's an extract:

Range("K19:L30").Select
Selection.Copy

I copy this range and paste it two columns to the left

Range("G19:H30").Select
Selection.PasteSpecial ...etc.

The problem is that the range constantly changes, is there any way to determine the range without me having to check on it manually every time, say based on some principle (e.g. color)?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Yep... Would need to know what "criteria" or "principle" determines the range...

i.e. What is the logic that will determine the range you want to use.
 
Upvote 0
And also, do not .select.

This is equivalent:

Code:
Range("K19:L30").Copy
 
Upvote 0
Sorry, I posted the same one twice.
 
Upvote 0
The range contains debit-credit values, and the issue is to copy the said range of a closing period to the range of the opening period at the beginning of every month (I've got criteria when the date of the month equals 1)
 
Upvote 0
Please read back the contribution of Sthrncali and reply to it.
After that, helpers can try to write the code if your logic is coherent and clear.
 
Upvote 0
You can certainly test if " Cell.Font.ColorIndex = 41", however this is not enough information to determine your range...

Would also need to know the scope... i.e.

Is it every cell on a worksheet that meets that criteria... Does that criteria define the left, right, upper, or lower bounds of your range... Is the range your trying to locate one cell, or a range of cells...

The more information your provide the better we are able to assist you...

Please clearly explain exactly what range you need the code to define...

I.E., Look in Row 1, between Col A and Z testing for Font.ColorIndex, when you find a match my range will be xyz relative to the match..
 
Upvote 0
You can certainly test if " Cell.Font.ColorIndex = 41", however this is not enough information to determine your range...

Would also need to know the scope... i.e.

Is it every cell on a worksheet that meets that criteria... Does that criteria define the left, right, upper, or lower bounds of your range... Is the range your trying to locate one cell, or a range of cells...

The more information your provide the better we are able to assist you...

Please clearly explain exactly what range you need the code to define...

I.E., Look in Row 1, between Col A and Z testing for Font.ColorIndex, when you find a match my range will be xyz relative to the match..

Let me try it this way:
If Column A contains "FY Trade" then look for the Range in Columns K & L based on Font Color with
Borders (xlEdgeTop)
.ColorIndex = xlAutomatic
.Weight = xlMedium
.LineStyle = xlContinuous
and
Borders (xlEdgeBottom)

In other words, would it be possible to define the range by top/bottom borders based on color criteria. Maybe even w/o column A containing a certain word?
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,448
Members
452,915
Latest member
hannnahheileen

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