Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Contents in Column

This code€¦.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim s As String
If Target.Column = 4 Then
Select Case (UCase(Target.Value))
Case "New1", "Old1": s = "Customer"
Case " Old2": s = "Assets"
Case " New2": s = "Short Term"
Case " Old3": s = "Long Term"
End Select
If s < "" Then Target.Offset(, 3).Value = s
End If
End Sub

Does this€¦.

-When a cell in Column D contains New1 or Old1, €śCustomer€ť is entered into
Column G in the same row.
-When a cell in Column D contains Old2, €śAssets€ť is entered into Column G in
the same row.
-When a cell in Column D contains New2, €śShortTerm€ť is entered into Column G
in the same row.
-When a cell in Column D contains Old3, €śLongTerm€ť is entered into Column G
in the same row.


To start using the code above I right click Sheet 1 and select view code and
then paste it inside. Can you help me make this code different so that when
I press Alt F8, I can run it using that interface?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Contents in Column

Try running this macro and feedback

Sub MyMacro1()

lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row

For lngRow = 1 To lngLastRow
Dim s As String
Select Case Range("D" & lngRow).Text
Case "New1", "Old1": s = "Customer"
Case " Old2": s = "Assets"
Case " New2": s = "Short Term"
Case " Old3": s = "Long Term"
End Select
If s < "" Then Range("G" & lngRow) = s
Next

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Sal" wrote:

This code€¦.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim s As String
If Target.Column = 4 Then
Select Case (UCase(Target.Value))
Case "New1", "Old1": s = "Customer"
Case " Old2": s = "Assets"
Case " New2": s = "Short Term"
Case " Old3": s = "Long Term"
End Select
If s < "" Then Target.Offset(, 3).Value = s
End If
End Sub

Does this€¦.

-When a cell in Column D contains New1 or Old1, €śCustomer€ť is entered into
Column G in the same row.
-When a cell in Column D contains Old2, €śAssets€ť is entered into Column G in
the same row.
-When a cell in Column D contains New2, €śShortTerm€ť is entered into Column G
in the same row.
-When a cell in Column D contains Old3, €śLongTerm€ť is entered into Column G
in the same row.


To start using the code above I right click Sheet 1 and select view code and
then paste it inside. Can you help me make this code different so that when
I press Alt F8, I can run it using that interface?

  #3   Report Post  
Posted to microsoft.public.excel.programming
Sal Sal is offline
external usenet poster
 
Posts: 84
Default Contents in Column

This is great. It works great. Thank you for your help.

"Jacob Skaria" wrote:

Try running this macro and feedback

Sub MyMacro1()

lngLastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row

For lngRow = 1 To lngLastRow
Dim s As String
Select Case Range("D" & lngRow).Text
Case "New1", "Old1": s = "Customer"
Case " Old2": s = "Assets"
Case " New2": s = "Short Term"
Case " Old3": s = "Long Term"
End Select
If s < "" Then Range("G" & lngRow) = s
Next

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Sal" wrote:

This code€¦.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim s As String
If Target.Column = 4 Then
Select Case (UCase(Target.Value))
Case "New1", "Old1": s = "Customer"
Case " Old2": s = "Assets"
Case " New2": s = "Short Term"
Case " Old3": s = "Long Term"
End Select
If s < "" Then Target.Offset(, 3).Value = s
End If
End Sub

Does this€¦.

-When a cell in Column D contains New1 or Old1, €śCustomer€ť is entered into
Column G in the same row.
-When a cell in Column D contains Old2, €śAssets€ť is entered into Column G in
the same row.
-When a cell in Column D contains New2, €śShortTerm€ť is entered into Column G
in the same row.
-When a cell in Column D contains Old3, €śLongTerm€ť is entered into Column G
in the same row.


To start using the code above I right click Sheet 1 and select view code and
then paste it inside. Can you help me make this code different so that when
I press Alt F8, I can run it using that interface?

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
VBA - Insert row, copy contents of original row except for contents of column A Royzer Excel Programming 4 February 21st 12 02:47 PM
How can I sort contents of one column based on the contents ofanother column? [email protected] Excel Programming 1 February 9th 08 12:29 PM
Fill a column with the contents of another column based on a choic Sparky56 Excel Discussion (Misc queries) 1 March 31st 07 04:18 AM
Please Help: Paste Column Contents to Next Available Column Without Data [email protected] Excel Programming 2 May 2nd 06 04:09 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


All times are GMT +1. The time now is 05:18 AM.

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"