Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default simple macro

Hi Folks

I have the following macro that, for the life of me, I can't seem to change so that it cuts the last 5 characters of a cell instead of the first 5 characters. Any help much appreicated.

Sub MoveAround()

Dim CellVal As String

CellVal = ActiveCell.Text
Range(ActiveCell.Address) = Right(CellVal, Len(CellVal) - 6)
ActiveCell.Offset(0, 1).Select
Range(ActiveCell.Address) = Left(CellVal, 6)
ActiveCell.Offset(1, -1).Select

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default simple macro

Joe

This worked for me

Sub test()

Dim CellText As String

CellText = ActiveCell.Text
ActiveCell.Value = Right(CellText, Len(CellText) - 6)
ActiveCell.Offset(0, 1).Value = Left(CellText, 6)

End Sub

There must be something wrong with the CellVal variable. Put this after the
CellVal assignment

MsgBox CellVal

and see if it's what you expect it to be.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"Joe" wrote in message
...
Hi Folks

I have the following macro that, for the life of me, I can't seem to

change so that it cuts the last 5 characters of a cell instead of the first
5 characters. Any help much appreicated.

Sub MoveAround()

Dim CellVal As String

CellVal = ActiveCell.Text
Range(ActiveCell.Address) = Right(CellVal, Len(CellVal) - 6)
ActiveCell.Offset(0, 1).Select
Range(ActiveCell.Address) = Left(CellVal, 6)
ActiveCell.Offset(1, -1).Select

End Sub



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
Help with simple macro Sam Commar Excel Discussion (Misc queries) 3 April 15th 08 04:30 PM
Simple macro MikeD1224 Excel Discussion (Misc queries) 1 June 9th 07 12:06 AM
Simple Macro John Excel Worksheet Functions 1 November 17th 06 05:16 PM
Simple Macro MAStew New Users to Excel 3 July 27th 06 10:50 PM
Simple Macro sparx Excel Discussion (Misc queries) 4 May 12th 06 06:25 AM


All times are GMT +1. The time now is 04:24 PM.

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"