Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Selecting 10 charcters on one cell and pasting to another cell

Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.

I can't figure it out.

Can someone help?
Tony

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Selecting 10 charcters on one cell and pasting to another cell

Here you go...

Sub ButtonName_Click()
ActiveCell.Offset(1,0) = Left(ActiveCell,10)
End Sub
--
Chris Farkas
Excel/Access Developer
http://www.eAlchemy.biz


" wrote:

Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.

I can't figure it out.

Can someone help?
Tony


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Selecting 10 charcters on one cell and pasting to another cell

this is what i came up with:

Option Explicit

Private Sub CommandButton1_Click()

Dim CurrentRow As Long
Dim TargetCell As Range
Dim myString As String
Dim DestCell As Range

CurrentRow = ActiveCell.Row

Set TargetCell = Range("d" & CurrentRow)

myString = Left(TargetCell.Value, Len(TargetCell) - 6)

Set DestCell = Range("h" & CurrentRow)

DestCell = myString


End Sub

but Chris' is much simpler.
oh well. :)
susan


On Feb 23, 8:44 am, wrote:
Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.

I can't figure it out.

Can someone help?
Tony



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Selecting 10 charcters on one cell and pasting to another cell

on 2nd thought, i don't think chris' does what you want it to, because
he's taking the value of the active cell instead of column d.
however, i found a bug in mine, that it only works properly if the
target cell is 16 characters.
so i think it'd be better to go from the right.

myString = right(TargetCell.Value, Len(TargetCell) 10)

susan


On Feb 23, 9:34 am, "Susan" wrote:
this is what i came up with:

Option Explicit

Private Sub CommandButton1_Click()

Dim CurrentRow As Long
Dim TargetCell As Range
Dim myString As String
Dim DestCell As Range

CurrentRow = ActiveCell.Row

Set TargetCell = Range("d" & CurrentRow)

myString = Left(TargetCell.Value, Len(TargetCell) - 6)

Set DestCell = Range("h" & CurrentRow)

DestCell = myString

End Sub

but Chris' is much simpler.
oh well. :)
susan

On Feb 23, 8:44 am, wrote:



Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Selecting 10 charcters on one cell and pasting to another cell

my mistake (didn't work) - just the "10" gives an error & should be
"+10", but that doesn't work. that line should be

myString = Left(TargetCell.Text, 10)

sorry!
(excuse me if this comes thru 2x, is giving me troubles)
susan


On Feb 23, 9:44 am, "Susan" wrote:
on 2nd thought, i don't think chris' does what you want it to, because
he's taking the value of the active cell instead of column d.
however, i found a bug in mine, that it only works properly if the
target cell is 16 characters.
so i think it'd be better to go from the right.

myString = right(TargetCell.Value, Len(TargetCell) 10)

susan

On Feb 23, 9:34 am, "Susan" wrote:



this is what i came up with:


Option Explicit


Private Sub CommandButton1_Click()


Dim CurrentRow As Long
Dim TargetCell As Range
Dim myString As String
Dim DestCell As Range


CurrentRow = ActiveCell.Row


Set TargetCell = Range("d" & CurrentRow)


myString = Left(TargetCell.Value, Len(TargetCell) - 6)


Set DestCell = Range("h" & CurrentRow)


DestCell = myString


End Sub


but Chris' is much simpler.
oh well. :)
susan


On Feb 23, 8:44 am, wrote:


Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Selecting 10 charcters on one cell and pasting to another cell

On 23 Feb, 14:50, "Susan" wrote:
my mistake (didn't work) - just the "10" gives an error & should be
"+10", but that doesn't work. that line should be

myString = Left(TargetCell.Text, 10)

sorry!
(excuse me if this comes thru 2x, is giving me troubles)
susan

On Feb 23, 9:44 am, "Susan" wrote:

on 2nd thought, i don't think chris' does what you want it to, because
he's taking the value of the active cell instead of column d.
however, i found a bug in mine, that it only works properly if the
target cell is 16 characters.
so i think it'd be better to go from the right.


myString = right(TargetCell.Value, Len(TargetCell) 10)


susan


On Feb 23, 9:34 am, "Susan" wrote:


this is what i came up with:


Option Explicit


Private Sub CommandButton1_Click()


Dim CurrentRow As Long
Dim TargetCell As Range
Dim myString As String
Dim DestCell As Range


CurrentRow = ActiveCell.Row


Set TargetCell = Range("d" & CurrentRow)


myString = Left(TargetCell.Value, Len(TargetCell) - 6)


Set DestCell = Range("h" & CurrentRow)


DestCell = myString


End Sub


but Chris' is much simpler.
oh well. :)
susan


On Feb 23, 8:44 am, wrote:


Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Hi Susan & Chris,
I have tried both methods and they both don't work.
I have tried variations on both your codes but no luck...any thoughts?

Thanks
Tony

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Selecting 10 charcters on one cell and pasting to another cell

I believe that eAlchemist had the right idea, just didn't get the
coordinates correct:

Sub ButtonName_Click()
ActiveCell.Offset(0, 1) = Left(ActiveCell.Offset(0, -3), 10)
End Sub

Regards,

Alan



wrote in message
ups.com...
Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.

I can't figure it out.

Can someone help?
Tony



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Selecting 10 charcters on one cell and pasting to another cell

On 24 Feb, 05:28, "Alan" wrote:
I believe that eAlchemist had the right idea, just didn't get the
coordinates correct:

Sub ButtonName_Click()
ActiveCell.Offset(0, 1) = Left(ActiveCell.Offset(0, -3), 10)
End Sub

Regards,

Alan

wrote in message

ups.com...

Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony


Working now,
Thanks everyone

Tony

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Selecting 10 charcters on one cell and pasting to another cell

alan - if you're still monitoring this thread - why didn't mine
work????
it worked for me........ what was i doing wrong?
thanks
susan


On Feb 24, 12:28 am, "Alan" wrote:
I believe that eAlchemist had the right idea, just didn't get the
coordinates correct:

Sub ButtonName_Click()
ActiveCell.Offset(0, 1) = Left(ActiveCell.Offset(0, -3), 10)
End Sub

Regards,

Alan

wrote in message

ups.com...



Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony- Hide quoted text -


- Show quoted text -



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Selecting 10 charcters on one cell and pasting to another cell

Hi Susan,

Your code works perfect, and you didn't do anything wrong. It worked, once
the myString line was changed to the line in your third message. I
personally like to keep my code as short as possible. If I can do the same
with less, I will always choose less. Tony's situation was ActiveCell
specific and not variable, so I tend to go the ActiveCell route since it
doesn't require much code.

I'm curious which route Mr. Ogilvy would choose in his own coding. Maybe he
will read this and respond.

Thanks for asking,

Alan

"Susan" wrote in message
ps.com...
alan - if you're still monitoring this thread - why didn't mine
work????
it worked for me........ what was i doing wrong?
thanks
susan


On Feb 24, 12:28 am, "Alan" wrote:
I believe that eAlchemist had the right idea, just didn't get the
coordinates correct:

Sub ButtonName_Click()
ActiveCell.Offset(0, 1) = Left(ActiveCell.Offset(0, -3), 10)
End Sub

Regards,

Alan

wrote in message

ups.com...



Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony- Hide quoted text -


- Show quoted text -







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Selecting 10 charcters on one cell and pasting to another cell

thanks very much for replying!
so mine worked, just was horribly over-written & inefficient. :) ha
ha
i'll get there someday!
thank you for helping me learn.
susan


On Feb 26, 2:30 pm, "Alan" wrote:
Hi Susan,

Your code works perfect, and you didn't do anything wrong. It worked, once
the myString line was changed to the line in your third message. I
personally like to keep my code as short as possible. If I can do the same
with less, I will always choose less. Tony's situation was ActiveCell
specific and not variable, so I tend to go the ActiveCell route since it
doesn't require much code.

I'm curious which route Mr. Ogilvy would choose in his own coding. Maybe he
will read this and respond.

Thanks for asking,

Alan

"Susan" wrote in message

ps.com...



alan - if you're still monitoring this thread - why didn't mine
work????
it worked for me........ what was i doing wrong?
thanks
susan


On Feb 24, 12:28 am, "Alan" wrote:
I believe that eAlchemist had the right idea, just didn't get the
coordinates correct:


Sub ButtonName_Click()
ActiveCell.Offset(0, 1) = Left(ActiveCell.Offset(0, -3), 10)
End Sub


Regards,


Alan


wrote in message


roups.com...


Hi,
For example, I am working on cell G8. I would like to set up a button
that, once clicked, copies and pastes the first 10 characters from D8
and pastes it into H8. The same process would apply if I am on G33,
i.e.copy first 10 characters from D33 and paste into H33, etc, etc.


I can't figure it out.


Can someone help?
Tony- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 single cell selecting muliple cell Submit2s Excel Worksheet Functions 1 February 12th 09 04:52 PM
Selecting a cell entry based on cell validation selection Brutalius Excel Worksheet Functions 2 December 17th 08 03:44 AM
Transfer cell values to another cell by selecting button. Gryndar Excel Worksheet Functions 2 November 24th 08 02:21 AM
Copying cell contents from many cells and pasting into one cell MDN Excel Discussion (Misc queries) 7 December 10th 07 08:56 PM
Selecting and pasting to an empty cell Craig from MI Excel Programming 1 March 7th 04 06:36 AM


All times are GMT +1. The time now is 03:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"