Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Need VB code to edit cell values

I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Need VB code to edit cell values

I'm not sure if I completely understand your question... does this code do
what you want?

With ActiveCell
.Offset(0, -1).Value = Left(.Value, Len(.Value) - 3)
.Value = Right(.Value, 3)
End With

--
Rick (MVP - Excel)


"Stephen Ford" wrote in message
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Need VB code to edit cell values

Seems my answer didn't make it to the group, this is the second try.
(just changed the befoer value of the StartCell to XXX,
seems M$ gets offended by x_y_z_ without the underscores)

I agree with Rick, I don't quite understand what you want to do.
As Don wrote, you should provide examples of how your data
looks before and how it should be after.
That's how I understand it:
LeftCell StartCell
befo ABCDE XXX
after: AB CDE

Is that what you want?

Helmut.


"Stephen Ford" schrieb im Newsbeitrag
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3 chars
present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need VB code to edit cell values

It's always worth another try... :-)
Yes that's it exactly

"Helmut Meukel" wrote in message
...
Seems my answer didn't make it to the group, this is the second try.
(just changed the befoer value of the StartCell to XXX,
seems M$ gets offended by x_y_z_ without the underscores)

I agree with Rick, I don't quite understand what you want to do.
As Don wrote, you should provide examples of how your data
looks before and how it should be after.
That's how I understand it:
LeftCell StartCell
befo ABCDE XXX
after: AB CDE

Is that what you want?

Helmut.


"Stephen Ford" schrieb im Newsbeitrag
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need VB code to edit cell values

Yes, I think that's it. I'll check... back soon.

"Rick Rothstein" wrote in message
...
I'm not sure if I completely understand your question... does this code do
what you want?

With ActiveCell
.Offset(0, -1).Value = Left(.Value, Len(.Value) - 3)
.Value = Right(.Value, 3)
End With

--
Rick (MVP - Excel)


"Stephen Ford" wrote in message
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Need VB code to edit cell values

This works
With ActiveCell
.Value = Right(.Offset(0, -1).Value, 3)
.Offset(0, -1).Value = Left(.Offset(0, -1).Value,
Len(.Offset(0, -1).Value) - 3)
End With
ActiveCell.Offset(1, 0).Activate

It changes
CellX CellY
A03001 XXX (before)
A03 001 (after)

The code ".Offset(0, -1).Value" is repeated a lot. Can a variable / object
or whatever be assigned and used instead?

CellY is text. If is gets a value like "001" the cells shows an error. I can
use the mouse to Ignore Error. Can this be programmed or can the error be
avoided another way?

"Stephen_Ford net" <stephen_fordNO@SPAMuwclub<dot wrote in message
...
Yes, I think that's it. I'll check... back soon.

"Rick Rothstein" wrote in message
...
I'm not sure if I completely understand your question... does this code
do what you want?

With ActiveCell
.Offset(0, -1).Value = Left(.Value, Len(.Value) - 3)
.Value = Right(.Value, 3)
End With

--
Rick (MVP - Excel)


"Stephen Ford" wrote in message
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Need VB code to edit cell values

The latest version uses a variable for the text in the cell to left of the
active cell-:
Dim LocTxt As String
With ActiveCell
LocTxt = .Offset(0, -1).Value
.Value = Right(LocTxt, 3)
.Offset(0, -1).Value = Left(LocTxt, Len(LocTxt) - 3)
End With
ActiveCell.Offset(1, 0).Activate

But I would like to know how to stop the error checking for Number as Text
in the active cell.


"Stephen_Ford net" <stephen_fordNO@SPAMuwclub<dot wrote in message
...
Yes, I think that's it. I'll check... back soon.

"Rick Rothstein" wrote in message
...
I'm not sure if I completely understand your question... does this code
do what you want?

With ActiveCell
.Offset(0, -1).Value = Left(.Value, Len(.Value) - 3)
.Value = Right(.Value, 3)
End With

--
Rick (MVP - Excel)


"Stephen Ford" wrote in message
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell







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
VB Code not grabbing cell values Morgan Excel Discussion (Misc queries) 5 March 3rd 10 01:55 PM
How to edit the code to fit image within specific cell? Eric Excel Programming 5 February 10th 10 06:12 AM
Code to do edit checks when user moves out of a cell Eric @ BP-EVV Excel Programming 1 April 24th 08 04:33 PM
Have code check cell contents on edit. Andrew Excel Worksheet Functions 1 January 16th 08 04:47 AM
UDF code to find specific text in cell comments, then average cell values bruch04 Excel Programming 3 December 5th 05 10:01 PM


All times are GMT +1. The time now is 08:14 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"