VBA Code to recognise that a drop down selection has been activated

NeilMG

New Member
Joined
Feb 21, 2012
Messages
5
Hi Team

I have developed a BP planning tool in Excel that shows, inter alia, 30 Year Cash Flows for Landlords who manage multiple properties. I have, on the face of that report, a drop down selection which enables the User to view the detailed Cash Flows either Including or Excluding the Cash Flows that relate to New Developments planned by the Landlord.

I want to be able to copy this Cash Flow Report to another Sheet initially Including New Development and then for the code to change that drop down to Excluding New Development and then copy this revised Cash Flow Report to the same sheet, but immediately below it; I can then calculate the changes in Cash Flows relating to New Development

I am not a coder myself, but do have a fairly good understanding when I view the code. I tried using the Macro Recorder initially, but this process failed to record the change affected by the drop down selection.

This is the Code generated:

Sub NewDevFunding()
'
' NewDevFunding Macro
'
Range("B3:AJ162").Select
Selection.Copy
Sheets("Wkg4 - General").Select
Range("B10944").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=154
Range("B11106").Select
Sheets("R3 Detailed Cash Flow").Select
Range("C6:C7").Select
Application.CutCopyMode = False
Range("B3:AJ162").Select
Selection.Copy
Sheets("Wkg4 - General").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A11103").Select
End Sub

My drop down cell is B7 on the Sheet "R3 Detailed Cash Flow"
as shown below
R3 - Detailed Cashflows - £000s - at Nominal Values
Select Cash Flow Basis and New Dev from drop downs…
Nominal_CF_Selected
Include_New_Dev

So when this macro runs, which will be button activated, what I need it to do is automatically check that for the 1st Copy the dropdown is selected as Include_New_Dev and, if not, change it before copying the report; it then needs to change the cell to Exclude_New_Dev then copy the report again.

I hope I have made my requirements clear and look forward to hearing back from one of you!

With Kind Regards
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Does this help any?
Yes it did thanks. Managed to find a bit of code that used the Replace fuction which sorted it very neatly - here is the code as I tested it - which works fine!

VBA Code:
    Dim OriginalText As String
    Dim CorrectedText As String
    Application.ScreenUpdating = False
    Application.Goto Reference:="SourceHome"
    OriginalText = Range("C4").Value
    CorrectedText = Replace(OriginalText, "Two", "One")
    Range("C4").Value = CorrectedText
    Range("C7:G7").Select
    Selection.Copy
    Application.Goto Reference:="ReportHome"
    Range("B2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.Goto Reference:="SourceHome"
    CorrectedText = Replace(OriginalText, "One", "Two")
    Range("C4").Value = CorrectedText
    Range("C7:G7").Select
    Application.CutCopyMode = False
    Selection.Copy
    Application.Goto Reference:="ReportHome"
    Range("B3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("D8").Select
    Application.Goto Reference:="SourceHome"
     CorrectedText = Replace(OriginalText, "Two", "One")
     Range("C4").Value = CorrectedText
    Application.Goto Reference:="ReportHome"
     Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Upvote 0
Good to hear! :) Thank you for the update!
Yes it did thanks. Managed to find a bit of code that used the Replace fuction which sorted it very neatly - here is the code as I tested it - which works fine!
 
Upvote 0

Forum statistics

Threads
1,216,419
Messages
6,130,515
Members
449,585
Latest member
kennysmith1

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