Hi can i have code fordoing something when specific cell selected?
Hi can i have code fordoing something when specific cell selected?
A mighty flame followeth a tiny sparkle!!
Hi there,
Something like this?
[vba]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$4" Then
MsgBox "Cell A4 has just been selected!"
End If
End Sub[/vba]
Must be placed in the code module for the worksheet you want it to work on.
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Yes like that only thanks
A mighty flame followeth a tiny sparkle!!
You're welcome!
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
One problem in thuis code
I'm unnble to perform cut & paste
A mighty flame followeth a tiny sparkle!!
This works for me.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$4" Then DoMove End If End Sub Sub DoMove() Application.EnableEvents = False Range("C4:C7").Cut Range("E4").Select ActiveSheet.Paste Application.EnableEvents = True End Sub
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
see this file containing macro
i am not able to perform cut(ctrl+x) & paste (ctrl+v) option after having this macro
A mighty flame followeth a tiny sparkle!!
You have some logic problems here
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$2" Then Application.MoveAfterReturnDirection = xlToLeft Else Application.MoveAfterReturnDirection = xlDown End If End Sub
Moving into cell A2 does change the direction to left, but you cannot go left. Clicking in any other cell returns the move direction to down.
Regarding the cut and paste, you do not show this bit of your code, but you need the Events disabled to prevent the worksheet change event ocurring when you select the cell where the code is to be pasted.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
I think u r not getting me
after using above code general cut & paste function is not working
see file submitted by me for detail
A mighty flame followeth a tiny sparkle!!
I see now! Sorry, I've no idea why this is happening, but maybe someone else can help.
For some reason it seems the cut/copied value is being lost from the clipboard when the Application line runs. I've tried Application.Calculate as well and the same problem occurs.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
I reposted your question here, for more assistance.
http://www.vbaexpress.com/forum/showthread.php?t=4650
It just seems to be the way the system works that is causing your problem
Regards
Malcolm
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'