Selecting the first cell in a selection, then the row of that cell

gbutton

New Member
Joined
Jan 23, 2014
Messages
35
So, my sheet is sorted in column H and the following code will select the first row with different information

Code:
Columns("H:H").Select
Selection.ColumnDifferences(ActiveCell).Select

Now, I need to select that row, copy it to a new tab, then find the next column difference. I seem to be having trouble figuring out how to select the row.

I'm pretty new, any help would be appreciated.
 
are you familiar with immediate window? (ctrl+g in vba window) you can test all of it there.
type
Code:
sheets(2).columns(1).select
or
Code:
?sheets(2).columns(1).address

so the above code select entire column of data (columns(1))
the rest is just simple "=COUNTIFS" worksheet function. It checks if the data on currently evaluated row (eg Appliques_Broad_Acanthus) is already in destination. if not, destrw will move one row down and the data will be pasted.

there are many approached selecting ranges on worksheet, my favorite one is using resize. U can google many info how it works, the basics are

range.resize(rowsToResize, colsToResize)

so if you do range("A1").reisize(2,2) you'll get A1:B2
same way you can use negative


and by "select everything to the left and right" I dont know what you want :/




 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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