ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to cancel the selection? (https://www.excelbanter.com/excel-programming/377036-how-cancel-selection.html)

xk

How to cancel the selection?
 
Hi,

I'm coding as the below lines to do copy some cells from one sheet to
another sheet

sheets(sheet1).Range(cell1:cell2),select
copy selection .... paste special .... etc

it works . but after that it goes to the orginal sheet and the selection
shinning line box still on the selection range. I'd like to not showing this
selection line after.

I tried selection .clear, but it just cleared all the content for the
selection, but I just want to cancel the selection

Is there anyone who can give the idea? Very appreicate for any help




Jim Thomlinson

How to cancel the selection?
 
Give this a try... It stores the original cell and sheet where the macro
started and then returns to that sheet and cell when the macro completes.

Sub Whatever()
dim rngOriginal as range
dim wksOriginal as Worksheet

set wksOriginal = activesheet
set rngoriginal = activecell
'Do your stuff

wksOriginal.Select
rngoriginal.Select
End Sub
--
HTH...

Jim Thomlinson


"xk" wrote:

Hi,

I'm coding as the below lines to do copy some cells from one sheet to
another sheet

sheets(sheet1).Range(cell1:cell2),select
copy selection .... paste special .... etc

it works . but after that it goes to the orginal sheet and the selection
shinning line box still on the selection range. I'd like to not showing this
selection line after.

I tried selection .clear, but it just cleared all the content for the
selection, but I just want to cancel the selection

Is there anyone who can give the idea? Very appreicate for any help




xk

How to cancel the selection?
 
Hi, Jim

I put your suggested code in my macro. but it didn't work as expected
And for additional info, I'm copying the cells from one sheet to a new add
sheet.
( I suppose that I can replace with any name for rngOriginal and wksOriginal
when do dim, right?)

Anyway, thanks for suggestion





"Jim Thomlinson" wrote:

Give this a try... It stores the original cell and sheet where the macro
started and then returns to that sheet and cell when the macro completes.

Sub Whatever()
dim rngOriginal as range
dim wksOriginal as Worksheet

set wksOriginal = activesheet
set rngoriginal = activecell
'Do your stuff

wksOriginal.Select
rngoriginal.Select
End Sub
--
HTH...

Jim Thomlinson


"xk" wrote:

Hi,

I'm coding as the below lines to do copy some cells from one sheet to
another sheet

sheets(sheet1).Range(cell1:cell2),select
copy selection .... paste special .... etc

it works . but after that it goes to the orginal sheet and the selection
shinning line box still on the selection range. I'd like to not showing this
selection line after.

I tried selection .clear, but it just cleared all the content for the
selection, but I just want to cancel the selection

Is there anyone who can give the idea? Very appreicate for any help




Susan

How to cancel the selection?
 
try adding this in

Application.CutCopyMode = False

after you've copied & pasted. this will remove the "cut" flashing box
around the selection.
susan


xk wrote:
Hi, Jim

I put your suggested code in my macro. but it didn't work as expected
And for additional info, I'm copying the cells from one sheet to a new add
sheet.
( I suppose that I can replace with any name for rngOriginal and wksOriginal
when do dim, right?)

Anyway, thanks for suggestion





"Jim Thomlinson" wrote:

Give this a try... It stores the original cell and sheet where the macro
started and then returns to that sheet and cell when the macro completes.

Sub Whatever()
dim rngOriginal as range
dim wksOriginal as Worksheet

set wksOriginal = activesheet
set rngoriginal = activecell
'Do your stuff

wksOriginal.Select
rngoriginal.Select
End Sub
--
HTH...

Jim Thomlinson


"xk" wrote:

Hi,

I'm coding as the below lines to do copy some cells from one sheet to
another sheet

sheets(sheet1).Range(cell1:cell2),select
copy selection .... paste special .... etc

it works . but after that it goes to the orginal sheet and the selection
shinning line box still on the selection range. I'd like to not showing this
selection line after.

I tried selection .clear, but it just cleared all the content for the
selection, but I just want to cancel the selection

Is there anyone who can give the idea? Very appreicate for any help





Jim Thomlinson

How to cancel the selection?
 
Are you doing any deleting?
--
HTH...

Jim Thomlinson


"xk" wrote:

Hi, Jim

I put your suggested code in my macro. but it didn't work as expected
And for additional info, I'm copying the cells from one sheet to a new add
sheet.
( I suppose that I can replace with any name for rngOriginal and wksOriginal
when do dim, right?)

Anyway, thanks for suggestion





"Jim Thomlinson" wrote:

Give this a try... It stores the original cell and sheet where the macro
started and then returns to that sheet and cell when the macro completes.

Sub Whatever()
dim rngOriginal as range
dim wksOriginal as Worksheet

set wksOriginal = activesheet
set rngoriginal = activecell
'Do your stuff

wksOriginal.Select
rngoriginal.Select
End Sub
--
HTH...

Jim Thomlinson


"xk" wrote:

Hi,

I'm coding as the below lines to do copy some cells from one sheet to
another sheet

sheets(sheet1).Range(cell1:cell2),select
copy selection .... paste special .... etc

it works . but after that it goes to the orginal sheet and the selection
shinning line box still on the selection range. I'd like to not showing this
selection line after.

I tried selection .clear, but it just cleared all the content for the
selection, but I just want to cancel the selection

Is there anyone who can give the idea? Very appreicate for any help




xk

How to cancel the selection?
 
Hi, Susan,

It's exactly the solution what I want. Thanks a lot.

And Jim

I don't delete the orgninal sheet, just use that one to link to the other
workbook and copy the data from this sheet to other sheets.

Thanks both of you for quick reply and idea.



"Susan" wrote:

try adding this in

Application.CutCopyMode = False

after you've copied & pasted. this will remove the "cut" flashing box
around the selection.
susan


xk wrote:
Hi, Jim

I put your suggested code in my macro. but it didn't work as expected
And for additional info, I'm copying the cells from one sheet to a new add
sheet.
( I suppose that I can replace with any name for rngOriginal and wksOriginal
when do dim, right?)

Anyway, thanks for suggestion





"Jim Thomlinson" wrote:

Give this a try... It stores the original cell and sheet where the macro
started and then returns to that sheet and cell when the macro completes.

Sub Whatever()
dim rngOriginal as range
dim wksOriginal as Worksheet

set wksOriginal = activesheet
set rngoriginal = activecell
'Do your stuff

wksOriginal.Select
rngoriginal.Select
End Sub
--
HTH...

Jim Thomlinson


"xk" wrote:

Hi,

I'm coding as the below lines to do copy some cells from one sheet to
another sheet

sheets(sheet1).Range(cell1:cell2),select
copy selection .... paste special .... etc

it works . but after that it goes to the orginal sheet and the selection
shinning line box still on the selection range. I'd like to not showing this
selection line after.

I tried selection .clear, but it just cleared all the content for the
selection, but I just want to cancel the selection

Is there anyone who can give the idea? Very appreicate for any help







All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com