Right and Left Function


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Right and Left Function

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    58

    Wink Right and Left Function

    I am hoping to find a way to make the code below work.

    Code:
    Sub test()
    
    Dim Dup As String
    Dim j As Integer
    
     For j = 3 To 21
            If ActiveSheet.Cells(j, "B").Text = Right(ActiveSheet.Cells(j, "B"), 3) Then
                ActiveSheet.Cells(j, "B").Value = Left(ActiveSheet.Cells(j, "G"), 7)
            End If
        Next j
    
    Dup = ActiveSheet.Cells(j, "B").Value
    
    MsgBox Dup
    
    End Sub
    Basically I have values in the 'A' Column that looks something Like This:

    WE12345dup

    I want the data to display like this:

    WE12345

  2. #2
    Join Date
    Aug 2007
    Posts
    58
    Sorry, I meant the 'B' Column.

  3. #3
    Join Date
    Nov 2007
    Posts
    11
    try using a formula

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by batman61
    try using a formula
    Any suggestions on what that formula would be?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Aug 2007
    Posts
    58
    I have this formula:

    Code:
    Range("A3").Select
        ActiveCell.Formula = _
        "=IF((RIGHT(A3,3)=""dup""),LEFT(A3,7),"""")"
        Selection.AutoFill Destination:=Range("A3:A5000"), Type:=xlFillDefault
    How do I assign it to some variable? This formula does not work because it creates a circular reference. However, I need the information in the 'A' Column.

    Any help will be greatly appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center