#1
|
|||
|
|||
concat based on selected cell
Hey all, so i'm not particularly good at vba (as you can see by my other 2 or 3 posts) but I do give it a go and try to figure it out. So I'm trying to get code to update the data of cell x if the active selected cell is in column y and not empty buuuut it's not working for me. This is what I have:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Target.Column = 15 And Target.Value <> "" Then ActiveSheet.Range("O9").Value = Target.Offset(1, 0) End If End If End Sub Any help |
#2
|
||||
|
||||
Well, your macro is doing what it's supposed to do. The only exception is that you have an extra "End If" (maybe only a typo).
Every time you click on a cell, if it's in column O and it isn't empty, then copy into the cell O9 the value of the cell of the row under the clicked cell. |
#3
|
|||
|
|||
to expand on the If statement a bit (i was also caught with this at the beginning)
If you have and if statment like Code:
If Target.Count > 1 Then Exit Sub but if you typed Code:
If Target.Count > 1 Then Exit Sub End If You also need to be carefull about nesting the if/end ifs correctly as it can cause problems |
#4
|
|||
|
|||
Thanks for the replies everyone! I was able to make it work for what I needed.
|
#5
|
||||
|
||||
Glad we were able to help .
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Paste value of selected cell to adjacent cell | Marcia | Excel Programming | 3 | 08-26-2021 12:55 AM |
Macro - Copying and Pasting selected slides (based on selected keywords/criteria) Hi | erickhawe | PowerPoint | 0 | 08-16-2019 09:00 PM |
Set Range based on selected rows. | 14spar15 | Excel Programming | 8 | 11-19-2018 08:08 AM |
Cell color based on cell value as compared to another cell va | COgreywolf | Excel | 9 | 09-25-2018 12:28 PM |
string concat stopped working? | AlexanderJohnWilley | Excel | 6 | 09-27-2013 08:39 PM |