Forum Discussion
action based on cell selection
- Apr 19, 2022
To achieve that, place the following codes on Sheet Module and to do that follow these steps...
1. Right click on Sheet Tab Name and choose View Code.
2. Paste the codes given below into the opened code window.
3. Save your file as Macro-Enabled Workbook.
Sheet Module Codes:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.CountLarge > 1 Then Exit Sub Dim NumToSum As Long If Target.Column = 1 And Target.Row > 1 Then Range("C1").ClearContents If Target <> "" And IsNumeric(Target.Value) Then NumToSum = getNumber(Range("B1").Value) If NumToSum <> 0 Then Range("C1").Value = NumToSum + Target.Value End If End If End If End Sub Function getNumber(ByVal str As String) As Long Dim Matches As Object With CreateObject("VBScript.RegExp") .Global = False .Pattern = "\d+" If .test(str) Then Set Matches = .Execute(str) getNumber = Matches(0) End If End With End Function
Please find the attached with codes in place.
tell me your favourite stock and i will buy one or you and sent you the profits (if any) 🙂
in v5 i'm not able to find last data cell in column
Thanks for the offer! 🙂
Please look at the attached and see if this helps. List the market holidays in column AA.
- drdree73Aug 15, 2023Brass Contributor
v7 was corrupt. v8 is attached.
i have not solved the dynamic range issue for displaying the graph
- drdree73Aug 14, 2023Brass Contributor
Thank you. Adding holidays would be too many manual labour 🙂.
I fixed now the issue with IF THEN ELSE in column J.
If date is TODAY use current (actual)
Final issue is that graph is not making complete data range selection per selected stock.