Multiply [Entire Column Range] by value, for only specified / certain [Column Headings]

Manerlao

Board Regular
Joined
Apr 14, 2020
Messages
56
Office Version
  1. 2019
Platform
  1. Windows
Hi Excel Community!

I need some kind help with the following VBA code. If anyone can please help, this would be great! It's been challenging to define this.

Goal:
I need to adjust all values in certain columns based on specific headings across multiple sheets.
I will store and run the macro from my PERSONAL Macro WB.

My headings span cell range A1 to around DT, so I have just stated the max range as Range("A1:DZ1") for the headings.

Basically I need to multiply all the values in the column for certain headings across the sheets in a workboo iF the value is larger than 1.

The values I am working with are percentages.
However, for some reason, they are all multiplied by 10. For example, 78.24% is noted incorrectly in the column as 7824%. So I need to multiply all the percentages by 0.01 to obtain the actual %.

The headings have different names: Heading1, Heading2, .... Heading 99, and they are contained within different sheets in the workbook.
I have a list of all the column headings already written down, so I can copy that into the Macro in the appropriate section.

I have been trying to build the following code without much success:


VBA Code:
Sub AdjustColValues()
'*******************

Dim Cell As Range, rngX As Range
Dim strFormat As String
Dim ws As Worksheet

'Headings are in cell range A1 a maximum of DZ1
    Set rngX = Range("A1:DZ1")
    For Each Cell In rngX
    With Cell
    
    Select Case True
    
    Case .Value Like "Heading1" OR like "Heading2"
    
        If Cell.Value > 1 Then
            For Each Cell In EntireColumn.Cells
                Cell.Value = Cell.Value * 0.01
            Next Cell
        Else
        
        End If
        
    End Select
    End With
    
    Next Cell

End Sub

Please let me know your thoughts and if anyone needs further information, please let me know. Thank you!

Manerlao
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,256
Messages
6,123,914
Members
449,132
Latest member
Rosie14

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