May I ask why you did not like my solution?

Sub TTC_SAS()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Columns("g:o").Delete

Columns("A").TextToColumns Destination:=Range("G1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(4, 1)), TrailingMinusNumbers:=True
    
Columns("C").TextToColumns Destination:=Range("I1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 3), Array(9, 1)), TrailingMinusNumbers:=True
    
Columns("D").TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="-"
    
Columns("E").TextToColumns Destination:=Range("N1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:="X"

Application.DisplayAlerts = True
Columns("f").Copy Range("p1")

Columns.AutoFit
Application.ScreenUpdating = True

End Sub

Don Guillett
SalesAid Software
dguille...@gmail.com

From: Darwin Chan 
Sent: Tuesday, January 31, 2012 2:17 AM
To: excel-macros@googlegroups.com 
Subject: Re: $$Excel-Macros$$ Splitting the values from 1 cell to 2 cells

Dear group, 
1. Based on the ideas from Paul, changing code can help me to get desired 
results.
  If IsEmpty(.Cells(R, "E")) Then
  .Cells(R, "N").Value = ""
  .Cells(R, "O").Value = ""
  ElseIf (InStr(.Cells(R, "E").Value, "X") > 0) Then
  .Cells(R, "N").Value = Left(.Cells(R, "E").Value, (InStr(.Cells(R, 
"E").Value, "X") - 1))
  .Cells(R, "O").Value = Mid(.Cells(R, "E").Value, (InStr(.Cells(R, "E").Value, 
"X") + 1), 3)
  Else
  .Cells(R, "N").Value = .Cells(R, "E").Value
  .Cells(R, "O").Value = ""
  End If
  .Cells(R, "P").Value = Cells(R, "F").Value
  Next R

2. A
However, as users have changed their mind, so I have to change the code for 
other parts. 

For step 2 in my code, the "sztyhg" (Column B in file) can determine other 
values in the file. 

Company code 
go to HHKHKGHKHKGRTT with third digit of "sztyhg" ="G"
go to HHKHKGHKHKGRT1 with third digit of "sztyhg" ="R"

Remark
same data as "sztyhg"

Man Rate O
go to 40 with third digit of "sztyhg" ="G" 
go to 48 with third digit of "sztyhg" ="R"  

2.B
But some other changes happened when I use original method to get damage code 
and repair code, it does not get the desired results as I want, could anyone 
help to find out what is the problem?


2012/1/31 Rajan_Verma <rajanverma1...@gmail.com>

  You can use Split method and Assign split values to range

  Range(“A1:C1”)=split(“A:B:C”,”:”)



  Rajan.





  From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On 
Behalf Of dguillett1
  Sent: Jan/Mon/2012 08:14
  To: excel-macros@googlegroups.com
  Subject: Re: $$Excel-Macros$$ Splitting the values from 1 cell to 2 cells



  oops. change o1 to p1



  Application.DisplayAlerts = True

  Columns("f").Copy Range("p1")



  Don Guillett
  SalesAid Software
  dguille...@gmail.com



  From: Darwin Chan 

  Sent: Sunday, January 29, 2012 11:03 PM

  To: excel-macros@googlegroups.com 

  Subject: $$Excel-Macros$$ Splitting the values from 1 cell to 2 cells



  Dear group, 



  I would like to get the value from 1 cell and split the value to 2 cells. Any 
VBA formula can help achieve this?



  Code starts from Private Sub CommandButton2_Click()



  Criteria: 

  Depends on the position of "X".

  If no value in original cell, just leave it blank.

  The value before "X" is length, the value after "X" is width.




  Attached can find sample for reference.



  -- 
  Darwin Chan 

  darwin.chankaw...@gmail.com

  kw42c...@yahoo.com.hk



  -- 
  FORUM RULES (986+ members already BANNED for violation)
   
  1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
   
  2) Don't post a question in the thread of another member.
   
  3) Don't post questions regarding breaking or bypassing any security measure.
   
  4) Acknowledge the responses you receive, good or bad.
   
  5) Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 
   
  NOTE : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
   
  
------------------------------------------------------------------------------------------------------
  To post to this group, send email to excel-macros@googlegroups.com

  -- 
  FORUM RULES (986+ members already BANNED for violation)
   
  1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
   
  2) Don't post a question in the thread of another member.
   
  3) Don't post questions regarding breaking or bypassing any security measure.
   
  4) Acknowledge the responses you receive, good or bad.
   
  5) Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 
   
  NOTE : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
   
  
------------------------------------------------------------------------------------------------------
  To post to this group, send email to excel-macros@googlegroups.com

  -- 
  FORUM RULES (986+ members already BANNED for violation)
   
  1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
   
  2) Don't post a question in the thread of another member.
   
  3) Don't post questions regarding breaking or bypassing any security measure.
   
  4) Acknowledge the responses you receive, good or bad.
   
  5) Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 
   
  NOTE : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
   
  
------------------------------------------------------------------------------------------------------
  To post to this group, send email to excel-macros@googlegroups.com





-- 
Darwin Chan 
darwin.chankaw...@gmail.com
kw42c...@yahoo.com.hk

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
 
------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to