Find the column by name and copy those values (divided/12)

GirishDhruva

Active Member
Joined
Mar 26, 2019
Messages
308
Hi everyone,
Below i have attached table , from which i need to search for a column through column name and when it finds that column it should perform some tasks like
1.It should divide by 12 from all the values which are found
2.Only that column should be copied and pasted in another new sheet with "Total at the bottom of that column"

[TABLE="width: 500"]
<tbody>[TR]
[TD]Basic[/TD]
[TD]HRA[/TD]
[TD]PF[/TD]
[TD]PT[/TD]
[TD]ESI[/TD]
[/TR]
[TR]
[TD]123[/TD]
[TD]35[/TD]
[TD]423[/TD]
[TD]23454[/TD]
[TD]12343[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]1343[/TD]
[TD]234524[/TD]
[TD]2345[/TD]
[TD]12354[/TD]
[/TR]
[TR]
[TD]123543[/TD]
[TD]13451[/TD]
[TD]1432[/TD]
[TD]51345[/TD]
[TD]514[/TD]
[/TR]
[TR]
[TD]35134[/TD]
[TD]54345[/TD]
[TD]5431[/TD]
[TD]54345[/TD]
[TD]543[/TD]
[/TR]
[TR]
[TD]53445[/TD]
[TD]51345[/TD]
[TD]4532[/TD]
[TD]145[/TD]
[TD]1345[/TD]
[/TR]
[TR]
[TD]3145[/TD]
[TD]32454[/TD]
[TD]134543[/TD]
[TD]5323[/TD]
[TD]5231[/TD]
[/TR]
[TR]
[TD]543245[/TD]
[TD]5423[/TD]
[TD]542534[/TD]
[TD]5413[/TD]
[TD]62354[/TD]
[/TR]
[TR]
[TD]14323[/TD]
[TD]6413[/TD]
[TD]643[/TD]
[TD]61423[/TD]
[TD]34564[/TD]
[/TR]
[TR]
[TD]42345[/TD]
[TD]12345[/TD]
[TD]4614[/TD]
[TD]36234[/TD]
[TD]46354[/TD]
[/TR]
</tbody>[/TABLE]

Thank you in advance
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi everyone,
Below i have attached table , from which i need to search for a column through column name and when it finds that column it should perform some tasks like
1.It should divide by 12 from all the values which are found
2.Only that column should be copied and pasted in another new sheet with "Total at the bottom of that column"

[TABLE="width: 500"]
<tbody>[TR]
[TD]Basic[/TD]
[TD]HRA[/TD]
[TD]PF[/TD]
[TD]PT[/TD]
[TD]ESI[/TD]
[/TR]
[TR]
[TD]123[/TD]
[TD]35[/TD]
[TD]423[/TD]
[TD]23454[/TD]
[TD]12343[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]1343[/TD]
[TD]234524[/TD]
[TD]2345[/TD]
[TD]12354[/TD]
[/TR]
[TR]
[TD]123543[/TD]
[TD]13451[/TD]
[TD]1432[/TD]
[TD]51345[/TD]
[TD]514[/TD]
[/TR]
[TR]
[TD]35134[/TD]
[TD]54345[/TD]
[TD]5431[/TD]
[TD]54345[/TD]
[TD]543[/TD]
[/TR]
[TR]
[TD]53445[/TD]
[TD]51345[/TD]
[TD]4532[/TD]
[TD]145[/TD]
[TD]1345[/TD]
[/TR]
[TR]
[TD]3145[/TD]
[TD]32454[/TD]
[TD]134543[/TD]
[TD]5323[/TD]
[TD]5231[/TD]
[/TR]
[TR]
[TD]543245[/TD]
[TD]5423[/TD]
[TD]542534[/TD]
[TD]5413[/TD]
[TD]62354[/TD]
[/TR]
[TR]
[TD]14323[/TD]
[TD]6413[/TD]
[TD]643[/TD]
[TD]61423[/TD]
[TD]34564[/TD]
[/TR]
[TR]
[TD]42345[/TD]
[TD]12345[/TD]
[TD]4614[/TD]
[TD]36234[/TD]
[TD]46354[/TD]
[/TR]
</tbody>[/TABLE]

Thank you in advance

Now i just need to sum that column ,which is divided by 12

Code:
Sub sum()
Dim sh As Worksheet
Dim Fnd As Range
Dim Nxt As Long
Dim Hdr As String
    Set sh = Sheets("Sheet2")
    Set Fnd = sh.Rows(3).Find("Basic", , xlValues, xlWhole)
    If Not Fnd Is Nothing Then
        Nxt = Cells(4, Columns.Count).End(xlToLeft).Offset(, 1).Column
        Hdr = Range(Cells(3, 1), Cells(3, Nxt - 1)).Address(, , xlR1C1)
        Range(Cells(4, Nxt), Cells(Rows.Count, Nxt - 1).End(xlUp).Offset(, 1)).FormulaR1C1 = "=SUMPRODUCT((" & Hdr & "=""Basic"")/12,(rc1:rc[-1]))"
        
    Else
        MsgBox "Search Item Not Found!"
        Exit Sub
    End If
End Sub

Thank you in advance
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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