+ Reply to Thread
Results 1 to 3 of 3

Macro under button that looks at a specific cell in the row and fills other cells

Hybrid View

  1. #1
    Registered User
    Join Date
    11-10-2016
    Location
    ANTWERP
    MS-Off Ver
    10
    Posts
    2

    Macro under button that looks at a specific cell in the row and fills other cells

    Hi guys,

    it's almost all in the title;

    How would a macro look if column Z contains a string and I want columns AA to show the first 2 characters and column BB to contain the rest of that string.

    I know this can easily be done with a formula but the working macro I have is too complex and uses live xml data so I prefer to work with a simple example instead of posting it here.

    I don't know the basics of VBA but have experience in coding so I can alter code but am not good at writing it from scratch.

    I'm just looking for a quick answer on how to
    -have a macro look at a specific cell in the current/selected row and
    -fill specific other cells in that same row using code that I already have so anything will do for this example

    Thank you so much!

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Macro under button that looks at a specific cell in the row and fills other cells

    Something like ...
    For a specific string
    With ActiveCell.EntireRow
       If .Cells(1, "Z") Like "Little Red*" Then
          .Cells(1, "AA") = Left(.Cells(1, "Z"), 2)
          .Cells(1, "BB") = Right(.Cells(1, "Z"), Len(.Cells(1, "Z")) - 2)
       End If
    End With
    Edit: fixed missing bracket

    For any string
    With ActiveCell.EntireRow
       If Len(.Cells(1, "Z"))>0 Then
          .Cells(1, "AA") = Left(.Cells(1, "Z"), 2)
          .Cells(1, "BB") = Right(.Cells(1, "Z"), Len(.Cells(1, "Z")) - 2)
       End If
    End With
    Last edited by Neil_; 11-10-2016 at 01:24 PM.
    Frob first, tweak later

  3. #3
    Registered User
    Join Date
    11-10-2016
    Location
    ANTWERP
    MS-Off Ver
    10
    Posts
    2

    Re: Macro under button that looks at a specific cell in the row and fills other cells

    Perfect! thanks so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Macro Button copy certain range cells on a specific value to next sheet
    By Jeffrey_ghost in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-16-2015, 04:39 PM
  2. Replies: 1
    Last Post: 04-13-2015, 08:34 PM
  3. Replies: 6
    Last Post: 06-17-2014, 11:11 AM
  4. Button to copy specific cells to another sheet, lock button if cell has text
    By elmerg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2014, 02:10 AM
  5. Command button code that fills two combo box values and a toggle in cell
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-03-2010, 12:03 AM
  6. Pop-up menu Macro that fills cells
    By alin_m in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-08-2010, 01:36 PM
  7. Macro that fills in cells needs to skip 2 rows
    By westonkw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2008, 05:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1