Macro Help - Validation List to summary tab

PghYoPro

New Member
Joined
Dec 9, 2015
Messages
23
Hello,

I had a similar problem a while back but I can't seem to find out why the macro is not working.


  • I have a sheet titled "Income Statement (% of TNPR)" with a validation dropdown in cell B2.
  • The validation dropdown data comes from cells B2:298 on a sheet titled "Data Validation".
  • I want the macro to cycle through the data validation list in cell B2 on "Income Statement (% of TNPR)" and return the results of cell E32 to an existing blank tab "Results" starting in cell A1. I also want the correlating dropdown name in cell B2 on "Income Statement (% of TNPR) to be placed starting in cell B1 on the "Results" tab

Here is the macro I am attempting to run:


Sub TNPR()
Dim i As Long
With ActiveSheet
For i = 2 To 298
.Range("B2").Value = Sheets("Data Validation").Range("B" & i).Value
ActiveSheet.Calculate
Sheets("results").Range("A" & i - 3).Value = .Range("E32").Value
ActiveSheet.Calculate
Sheets("results").Range("B" & i - 3).Value = .Range("B2").Value
Next i
End With
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hello,


  • I have a sheet titled "Income Statement (% of TNPR)" with a validation dropdown in cell B2.
  • The validation dropdown data comes from cells B2:298 on a sheet titled "Data Validation".
  • I want the macro to cycle through the data validation list in cell B2 on "Income Statement (% of TNPR)" and return the results of cell E32 to an existing blank tab "Results" starting in cell A1. I also want the correlating dropdown name in cell B2 on "Income Statement (% of TNPR) to be placed starting in cell B1 on the "Results" tab



Sub TNPR()
Dim i As Long
With ActiveSheet
For i = 2 To 298
.Range("B2").Value = Sheets("Data Validation").Range("B" & i).Value
ActiveSheet.Calculate
Sheets("results").Range("A" & i - 3).Value = .Range("E32").Value
ActiveSheet.Calculate
Sheets("results").Range("B" & i - 3).Value = .Range("B2").Value
Next i
End With
End Sub

Well... If nothing Else, the first 2 iterations of your 'For' loop would cause issues I think.

@ i = 2 :

Range("A" & i - 3) -> Range("A-1") when in fact, I think you are looking for it to be -> Range("A1")

Try using (1's instead of 3's)

Code:
ActiveSheet.Calculate
Sheets("results").Range("A" & i - 1).Value = .Range("E32").Value
ActiveSheet.Calculate
Sheets("results").Range("B" & i - 1).Value = .Range("B2").Value

Hope that helps
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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