My expected result is:
1. A picture is selected manually
(e.g. picture with left top corner at L3)
2. The picture can move to K3 by VBA.
(NB. Width of Column K may be varied time to time)
Enclosed with excel for reference.
My expected result is:
1. A picture is selected manually
(e.g. picture with left top corner at L3)
2. The picture can move to K3 by VBA.
(NB. Width of Column K may be varied time to time)
Enclosed with excel for reference.
this will move the selection to the left 1 column
Please Login or Register to view this content.
Thanks Andy Pope.
How to advise VBA to suit my actual case as follows:
1. Active cell is at say L3.
2. By VBA, picture at location of cell (L3) is selected.
3. By VBA, the picture will move horizontally to column B (B3).
Please Login or Register to view this content.
Hobson,
The VBA cannot work.
Enclosed with excel for your testing.
I don't know what can not work means. I already tested it. It worked exactly as you wanted in #3. It moves the selected picture object to column B, topleft. The 2nd attachment is the same and works as well.
Your object has a border so your perception of edges may not be what they actually are.
Hobson,
It's work if I manually select picture at L3 first.
How to revise VBA if:
1. The activecell moves to say L3 manually.
2. The picture at activecell (L3) is selected by VBA.
3. The rest is same as your original VBA.
Manually selecting the picture object is what you said that you wanted in #1 and #3.
If you want a cell selection worksheet event then right click your worksheet's tab, View > Code, and paste this. This solution also meets the needs of your other similar post. Just change L3 to your range address in the Intersect line.
Please Login or Register to view this content.
Hobson,
I don't know how to function this type of VBA with "Private".
I have copied all code by right click the worksheet's tab (Sheet 1) and View Code (V)
as per attached excel.
However when I press ALT-F8, there is no Macro and hence I can't set shortcut key.
Please advise.
Hi london7871,
1st no picture topleftcell at L3. It is loacated at L2.
You can try to amend Mr. Kenneth Hobson expert the codes as below:
Please Login or Register to view this content.
ikboy,
1. How to set shortcut key to the amended VBA?
(if ALT-F8 and then (E) are pressed, there is above VBA code but there is no Macro name if press ALT-F8)
2. How to revise above so that the picture at activecell (L2) can be selected by VBA?
(i.e. if activecell moves to say L59, picture at L59 can be selected by VBA)
london7871,
1. Just follow the steps how you copy the codes to (sheet 1)... I have copied all code by right click the worksheet's tab (Sheet 1) and...
2. VBA can find pictures and let you go to the topledtcell of each. Please note "move" and "goto" are very difference meaning in VB.
ikboy,
1.How to set shortcut key for your VBA?
(I don't want it starts automatically)
2. How to revise VBA if I move cell manually to another cell (say L59), picture at that cell (L59) can be selected by VBA and move to col B?
Last edited by london7871; 07-18-2016 at 06:31 AM.
Try to stay on the topic. IF you need to ask an urelated question, post another thread. e.g. How to set a hotkey to play a macro. A simple search will find many link for how to do that. https://support.office.com/en-us/art...4-99a49f1dcdf4
Try to understand concepts so that you can modify code. I already explained how to change the Intersect() code line to suit.
Delete the worksheet code from earlier, and paste this to a Module.
Please Login or Register to view this content.
How to revise VBA if the pictures may not at Col L, may be at another column instead.
You don't know how to change "L" to "P" or "Q" or....?
From my last post:
Press F1 with cursor in or next to a command word like Intersect() if you need help.Try to understand concepts so that you can modify code. I already explained how to change the Intersect() code line to suit.
Last edited by Kenneth Hobson; 07-18-2016 at 11:51 AM.
I want to cover all pictures in columns L to P as the location of pictures may be changed each time.
[Original query to be deleted :
I want to set to say P or Q etc. by VBA according to actual location of pictures.]
Last edited by london7871; 07-19-2016 at 12:15 AM. Reason: Range changes from "P or Q" to "L to Q"
Thanks Hobson,
The VBA works if the code is revised as follows:
Set r = Intersect(ActiveCell, Columns("L:P"))
Also thanks to ikboy and Andy Pope for help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks