Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Paste With A Custom Format

Greetings,

I am passing a string of characters in the format like this: 123abc45

I would like to have it show up after pasting as: 123A <BC-45

The code I am using to paste with now is:

Select Case Target.Column
Case 3
For i = 1 To 118
With ws1_1.Range("InvData" & i)
Select Case i
Case 4 'Cust List data
.Value = _
ws2_1.Range("MCL_Name").Offset(ws1_1 _
.Range("MyRowNum").Value - 1, 60).Value
I tried to wrap the last line with this format:

Format(ws2_1.Range("MCL_Name").Offset(ws1_1 _
.Range("MyRowNum").Value - 1, 60).Value, "#### <##-##")

And get a type mismatch.

How can I get this custom format at the destination cell?

Any help is really appreciated, Thanks.

-Minitman



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Paste With A Custom Format

hi
small problem. 123abc45 is text. you cannot "format" text. you can only
format numbers. that is where you are getting your type mismatch error.
for text you have to do something like this.
I was have trouble with your ranges so assuming 123abc45 is in a1.......
Sub stringtest()
Dim s As String
s = Range("A1").Value
Range("A2").Value = _
"'" & Left(s, 4) & "<" & Mid(s, 5, 2) & "" & Right(s, 2)
End Sub

regards
FSt1

"Minitman" wrote:

Greetings,

I am passing a string of characters in the format like this: 123abc45

I would like to have it show up after pasting as: 123A <BC-45

The code I am using to paste with now is:

Select Case Target.Column
Case 3
For i = 1 To 118
With ws1_1.Range("InvData" & i)
Select Case i
Case 4 'Cust List data
.Value = _
ws2_1.Range("MCL_Name").Offset(ws1_1 _
.Range("MyRowNum").Value - 1, 60).Value
I tried to wrap the last line with this format:

Format(ws2_1.Range("MCL_Name").Offset(ws1_1 _
.Range("MyRowNum").Value - 1, 60).Value, "#### <##-##")

And get a type mismatch.

How can I get this custom format at the destination cell?

Any help is really appreciated, Thanks.

-Minitman




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default Paste With A Custom Format

Thanks for the reply FSt1,

Looking at the problem a bit deeper, it seems that this piece of data
is coming from a different workbook. Out of 118 cells, about 45 are
getting their figures from this external workbook. these are working
fine!!! I will have to look into why this one can't seem to see it's
data in this workbook.

I have to give up for tonight (I have an early morning appointment).

Since this a logic screw-up, trying to explain what is going in will
probably reveal the problem, if not I'll be back with better
information.

-Minitman

btw: I realized that I had asked this question in a slightly
different way back on July 8, 2007 and received these replies:

Target.Value = "Map " & UCase(Left(Target.Value, 4)) & " <" & _
UCase(Mid(Target.Value, 5, 2)) & "-" & Right(Target.Value, 2) & ""



This is going to seem like magic<g...

Your above line of code can be replaced with this...

Target.Value = Format(Target.Value, "!Map @@@@ \<@@-@@\")

Rick Rothstein \(MVP - VB\)


For your information :^)



On Mon, 6 Apr 2009 20:47:01 -0700, FSt1
wrote:

hi
small problem. 123abc45 is text. you cannot "format" text. you can only
format numbers. that is where you are getting your type mismatch error.
for text you have to do something like this.
I was have trouble with your ranges so assuming 123abc45 is in a1.......
Sub stringtest()
Dim s As String
s = Range("A1").Value
Range("A2").Value = _
"'" & Left(s, 4) & "<" & Mid(s, 5, 2) & "" & Right(s, 2)
End Sub

regards
FSt1

"Minitman" wrote:

Greetings,

I am passing a string of characters in the format like this: 123abc45

I would like to have it show up after pasting as: 123A <BC-45

The code I am using to paste with now is:

Select Case Target.Column
Case 3
For i = 1 To 118
With ws1_1.Range("InvData" & i)
Select Case i
Case 4 'Cust List data
.Value = _
ws2_1.Range("MCL_Name").Offset(ws1_1 _
.Range("MyRowNum").Value - 1, 60).Value
I tried to wrap the last line with this format:

Format(ws2_1.Range("MCL_Name").Offset(ws1_1 _
.Range("MyRowNum").Value - 1, 60).Value, "#### <##-##")

And get a type mismatch.

How can I get this custom format at the destination cell?

Any help is really appreciated, Thanks.

-Minitman





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
how to paste values created by custom format? oli merge Excel Discussion (Misc queries) 10 March 6th 12 11:23 PM
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Format Cell as custom type but data doesn't display like I custom. ToMMie Excel Discussion (Misc queries) 6 September 11th 08 08:31 AM
Excel 2003. Custom format gets replaced by Special format. jasper New Users to Excel 0 September 1st 08 03:46 AM
Custom Cell format to mimic time format [email protected] Excel Discussion (Misc queries) 6 November 7th 06 09:17 PM


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