Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
simple macro
try this
Sub cut5() On Error Resume Next ActiveCell = Left(ActiveCell, (Len(ActiveCell) - 5)) End Sub -- Don Guillett SalesAid Software "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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help with simple macro | Excel Discussion (Misc queries) | |||
Simple macro | Excel Discussion (Misc queries) | |||
Simple Macro | Excel Worksheet Functions | |||
Simple Macro | New Users to Excel | |||
Simple Macro | Excel Discussion (Misc queries) |