Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Move cell contents to another column IF

I have a listing of items and one column is now a combination of detail
lines, and product part #'s. I need to be able to seperate the two. The two
types appear in no particular order or sequence that is consistant.

One characteristic of the part #'s is that they always start with at least
two capital letters. Sometimes there are more caps, but at least 2.

Is there a way to move the contents of a cell IF the first two letters of
the cell are caps? Example below.

What I have now:
Col A Col B Col C
1 AB123
1 Outdoor
1 BC456
1 DEF980
1 Indoor

What I want to end up with:
Col A Col B Col C
1 AB123
1 Outdoor
1 BC456
1 DEF980
1 Indoor
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Move cell contents to another column IF

Hello Scott,
'----------------
Sub TestFirstTwoCharacters()
Dim rngCell As Excel.Range
Dim lngChar1 As Integer
Dim lngChar2 As Integer
Dim strText As String

For Each rngCell In Selection.Cells
strText = rngCell.Text
If Len(strText) Then
lngChar1 = Asc(strText)
lngChar2 = Asc(Mid$(strText, 2, 1))

If lngChar1 64 And lngChar1 < 91 Then
If lngChar2 64 And lngChar2 < 91 Then
rngCell(1, 2).Value = strText
rngCell.ClearContents
End If
End If
End If
Next 'rngCell
End Sub
'----------------------
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Scott Wagner"
wrote in message...
I have a listing of items and one column is now a combination of detail
lines, and product part #'s. I need to be able to seperate the two. The two
types appear in no particular order or sequence that is consistant.
One characteristic of the part #'s is that they always start with at least
two capital letters. Sometimes there are more caps, but at least 2.
Is there a way to move the contents of a cell IF the first two letters of
the cell are caps? Example below.

What I have now:
Col A Col B Col C
1 AB123
1 Outdoor
1 BC456
1 DEF980
1 Indoor

What I want to end up with:
Col A Col B Col C
1 AB123
1 Outdoor
1 BC456
1 DEF980
1 Indoor
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Move cell contents to another column IF

AWESOME!

Thanks Jim!

"Jim Cone" wrote:

Hello Scott,
'----------------
Sub TestFirstTwoCharacters()
Dim rngCell As Excel.Range
Dim lngChar1 As Integer
Dim lngChar2 As Integer
Dim strText As String

For Each rngCell In Selection.Cells
strText = rngCell.Text
If Len(strText) Then
lngChar1 = Asc(strText)
lngChar2 = Asc(Mid$(strText, 2, 1))

If lngChar1 64 And lngChar1 < 91 Then
If lngChar2 64 And lngChar2 < 91 Then
rngCell(1, 2).Value = strText
rngCell.ClearContents
End If
End If
End If
Next 'rngCell
End Sub
'----------------------
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Scott Wagner"
wrote in message...
I have a listing of items and one column is now a combination of detail
lines, and product part #'s. I need to be able to seperate the two. The two
types appear in no particular order or sequence that is consistant.
One characteristic of the part #'s is that they always start with at least
two capital letters. Sometimes there are more caps, but at least 2.
Is there a way to move the contents of a cell IF the first two letters of
the cell are caps? Example below.

What I have now:
Col A Col B Col C
1 AB123
1 Outdoor
1 BC456
1 DEF980
1 Indoor

What I want to end up with:
Col A Col B Col C
1 AB123
1 Outdoor
1 BC456
1 DEF980
1 Indoor

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 move contents in column up one cell pmt Excel Worksheet Functions 2 April 16th 09 03:47 PM
move contents of column C based on criteria related to column A Debra Excel Discussion (Misc queries) 2 December 27th 05 10:25 PM
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Move contents of entire column Matthew[_11_] Excel Programming 4 May 27th 04 04:25 PM
Macro to move selected cell contents to a specific column on same row Ben Johnson[_3_] Excel Programming 1 February 10th 04 08:43 PM


All times are GMT +1. The time now is 06:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"