Excel Macro Code

Dharmesh Thakkar

New Member
Joined
Oct 23, 2009
Messages
45
Dear Sir,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
My excel sheet data range is A4 to Z200(or AZ500). I would like to code for below, please help me
<o:p> </o:p>
if active cell is on say cell no H15, value of A15(same row) and C15(same row) appear on H2(same column) and H3(same column).
<o:p> </o:p>
if active cell is on say cell no K90, value of A90(same row) and C90(same row) appear on <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:place w:st="on">K2</st1:place>(same column) and K3(same column).
<o:p> </o:p>
Many thanks for help
<o:p> </o:p>
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Dharmesh Thakkar,

Maybe this ....
Code:
Sub Macro_ActiveCell()
    Dim ActCol As Single
    Dim ActRow As Single
    ActCol = ActiveCell.Column
    ActRow = ActiveCell.Row
    Worksheets("Sheet1").Cells(2, ActCol).Value = Worksheets("Sheet1").Cells(ActRow, 1).Value & Worksheets("Sheet1").Cells(ActRow, 3).Value
    Worksheets("Sheet1").Cells(3, ActCol).Value = Worksheets("Sheet1").Cells(ActRow, 1).Value & Worksheets("Sheet1").Cells(ActRow, 3).Value
End Sub
 
Upvote 0
Re: Excel Macro Code-Revise

Dear Sir,

code which you provided below is not working


Please ignore above and read as below

Dear Sir,

My excel sheet data range is A4 to Z200(or AZ500). I would like to code for below, please help me

if active cell is on say cell no H15, value of A15(same row) and C15(same row) appear on A2 and A3 respectively

if active cell is on say cell no K90, value of A90(same row) and C90(same row) appear on A2 and A3 respectively

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

i.e. value of column A & C of active row, should appear on A2 & A3 respectively<o:p></o:p>
<o:p> </o:p>

Many thanks for help<o:p></o:p>
<o:p> </o:p>
 
Upvote 0
Dear Dharmesh Thakkar,

First code was Ok because you would like value appear on same column of active cell:
appear on H2(same column) and H3(same column)
Now you change to:
appear on A2 and A3 respectively

Anyway, if I understand you correctly this should work
1. let say value of A15 is “Abu”, value of cell C15 is “Dhabi” & active cell is H15 (selected cell) then after running macro below the value on A2 & A3 will be “AbuDhabi”
2. let say value of A90 is “Good”, value of cell C90 is “Morning” & active cell is K90 (selected cell) then after running macro below the value on A2 & A3 will be “GoodMorning”
Code:
Sub Macro_ActiveCell()
    Dim ActCol As Single
    Dim ActRow As Single
    ActCol = ActiveCell.Column
    ActRow = ActiveCell.Row
    Range("A2") = Worksheets("Sheet1").Cells(ActRow, 1).Value & Worksheets("Sheet1").Cells(ActRow, 3).Value
    Range("A3") = Worksheets("Sheet1").Cells(ActRow, 1).Value & Worksheets("Sheet1").Cells(ActRow, 3).Value
End Sub

Please let me know if any problems.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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