Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-21-2021, 12:43 PM
Javi78503 Javi78503 is offline concat based on selected cell Windows 10 concat based on selected cell Office 2019
Novice
concat based on selected cell
 
Join Date: Jul 2021
Posts: 8
Javi78503 is on a distinguished road
Default 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
The reason I'm trying to do this is to contcat data from various cells into one a visible part of the screen. Most of my data takes up all the screen so if i want to concat something I have to do it off screen row by row. I'm trying to get it so it concats the info i need at the top of the table I'm using based on the row of the cell I have selected.

Any help
Reply With Quote
  #2  
Old 09-21-2021, 02:59 PM
rollis13's Avatar
rollis13 rollis13 is offline concat based on selected cell Windows 10 concat based on selected cell Office 2016
Advanced Beginner
 
Join Date: Jan 2021
Location: Cordenons
Posts: 48
rollis13 is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 09-24-2021, 07:41 PM
Purfleet Purfleet is offline concat based on selected cell Windows 10 concat based on selected cell Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 335
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

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
Where you have the comparison and end it on the same line you dont use end if

but if you typed
Code:
If Target.Count > 1 Then
    Exit Sub
End If
you would need the end if

You also need to be carefull about nesting the if/end ifs correctly as it can cause problems
Reply With Quote
  #4  
Old 10-13-2021, 09:03 AM
Javi78503 Javi78503 is offline concat based on selected cell Windows 10 concat based on selected cell Office 2019
Novice
concat based on selected cell
 
Join Date: Jul 2021
Posts: 8
Javi78503 is on a distinguished road
Default

Thanks for the replies everyone! I was able to make it work for what I needed.
Reply With Quote
  #5  
Old 10-13-2021, 09:27 AM
rollis13's Avatar
rollis13 rollis13 is offline concat based on selected cell Windows 10 concat based on selected cell Office 2016
Advanced Beginner
 
Join Date: Jan 2021
Location: Cordenons
Posts: 48
rollis13 is on a distinguished road
Default

Glad we were able to help .
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
concat based on selected cell 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
concat based on selected cell Set Range based on selected rows. 14spar15 Excel Programming 8 11-19-2018 08:08 AM
concat based on selected cell Cell color based on cell value as compared to another cell va COgreywolf Excel 9 09-25-2018 12:28 PM
concat based on selected cell string concat stopped working? AlexanderJohnWilley Excel 6 09-27-2013 08:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft