Select Specific Row in Active Column

pjhtechnology

New Member
Joined
Mar 13, 2010
Messages
7
Using Excel 2007 - this needs to also work in Excel 2003

I need to create a Macro for the following

Copy Row 1 thru 4 of the column for the Active.Cell to Row 1 thru 4 of the column to the right of the Active.Cell (the active cell will be wherever the user left the cursor in the column used)

If I can get through selecting the Rows I think I can figure out the rest

So far I found the code below which works to select Column A for the Active.Cell
Range("A" & ActiveCell.Row).Select
I have not be able to successfully modify this code to select Row 1 instead - Here's what I've tried
Range("1" & ActiveCell.Column).Select
Range(1 & ActiveCell.Column).Select
Obviously Selecting only Row 1 doesn't complete what I need - if you can help with the whole thing terrific - if you can help with any part of it also terrific

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
This isn't the most elegant, but it's basic and should at least make sense for you:

Code:
Sub CopyTop()
    Dim lFromCol As Long, _
        lToCol As Long, _
        wksSheet As Worksheet, _
        lRowCounter As Long
        
    Set wksSheet = ActiveSheet
    lFromCol = ActiveCell.Column
    lToCol = lFromCol + 1
    
    For lRowCounter = 1 To 4
        wksSheet.Cells(lRowCounter, lToCol).Value = wksSheet.Cells(lRowCounter, lFromCol).Value
    Next lRowCounter
    
End Sub
 
Upvote 0
pjhtechnology,

If I understand you correctly.

In the below screenshot, cell B8 is the active cell before the macro:


Excel Workbook
ABC
1A1B1
2A2B2
3A3B3
4A4B4
5A5B5
6A6B6
7A7B7
8A8B8
9A9B9
10A10B10
Sheet1





After the macro:


Excel Workbook
ABC
1A1B1B1
2A2B2B2
3A3B3B3
4A4B4B4
5A5B5
6A6B6
7A7B7
8A8B8
9A9B9
10A10B10
Sheet1





The active cell is now A1, and, after the macro:


Excel Workbook
ABC
1A1A1B1
2A2A2B2
3A3A3B3
4A4A4B4
5A5B5
6A6B6
7A7B7
8A8B8
9A9B9
10A10B10
Sheet1





If I select row 6, before the macro, there is not way to select an individual cell. The default active cell will always be in column A:


Excel Workbook
ABC
1A1B1
2A2B2
3A3B3
4A4B4
5A5B5
6A6B6
7A7B7
8A8B8
9A9B9
10A10B10
Sheet1





After the macro:


Excel Workbook
ABC
1A1A1
2A2A2
3A3A3
4A4A4
5A5B5
6A6B6
7A7B7
8A8B8
9A9B9
10A10B10
Sheet1





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Code:
Option Explicit
Sub Test()
' hiker95, 03/19/2010
Dim ActCol As Long
ActCol = ActiveCell.Column
Range(Cells(1, ActCol), Cells(4, ActCol)).Copy Cells(1, ActCol + 1)
End Sub



Select a cell, and then run macro "Test".
 
Upvote 0

Forum statistics

Threads
1,214,996
Messages
6,122,636
Members
449,092
Latest member
bsb1122

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