add a button on the worksheet close to range A57D62 Write VB
add a button on the worksheet close to range A57:D62. Write VBA code to find the maximum men to women ratios for states from the data obtained in Task 4 for all the years. Find the states and years when maximum men to women ratios are obtained and display the results starting from the cell A57. The text of the information “Highest men to women ratio years and their states” is displayed in cell A57. The text of “Highest Ratio” and maximum men to women ratio is displayed in cell A58 and A59 respectively. The headers for table are displayed in cells A59 and B59 and data in the following rows. All results of the VBA code are displayed when the button added on the worksheet is clicked.
Solution
Assuming that the data in the worksheet is available in the following format:
Column A : State
Column B: Year
Column C: Men
Column D: Women
Private Sub CommandButton1_Click()
Call compare_cols()
End Sub
End IF
End For
