+ Reply to Thread
Results 1 to 5 of 5

VBA - Help to move text from one column to another!!

  1. #1
    Registered User
    Join Date
    02-19-2022
    Location
    Yorkshire, England
    MS-Off Ver
    2019
    Posts
    2

    Unhappy VBA - Help to move text from one column to another!!

    Hi there

    I'm really new to VBA and could really do with some help on something I am trying to achieve. I thought it would be simple however, I just cant seem to figure it out even after searching the net for hours.

    I have names in column A and text in column B, and want to move text from column B to Column C if a certain word is found in column A and everything else from Column B to move to column D if the criteria is not met.

    I have this so far that seems to work if I do 1 row at a time, but surely there has to be an easier way:

    Public Sub MoveOperatorOver()

    Dim Person As String


    'For row 1
    Person = Range("A1").Value

    If Person = "Operator" Then
    Range("B1").Cut Range("C1")

    Else: Range("B1").Cut Range("D1")

    End If


    'For row 2
    Person = Range("A2").Value

    If Person = "Operator" Then
    Range("B2").Cut Range("C2")

    Else: Range("B2").Cut Range("D2")

    End If



    End Sub




    Any help would be greatly appreciated!!!

    Many thanks in advance!!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA - Help to move text from one column to another!!

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: VBA - Help to move text from one column to another!!

    Using something more like you have already, one way would be to create a loop;
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA - Help to move text from one column to another!!

    Quote Originally Posted by chojintrog View Post
    I have this so far that seems to work if I do 1 row at a time, but surely there has to be an easier way:
    Formula based code
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-19-2022
    Location
    Yorkshire, England
    MS-Off Ver
    2019
    Posts
    2

    Re: VBA - Help to move text from one column to another!!

    Wow!! 3 different methods from 3 different countries and the methods all work!! Thank you so much guys, this is just what I needed! I actually spent almost all day on this yesterday and tried to get loops in and all sorts, but couldn't get it to work.

    Much appreciated, you've all been a great help!!

+ 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] How to move remaining cells in a column to a new column every time a text is seen
    By planjb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2020, 10:11 AM
  2. [SOLVED] Find certain Text in a column then move those cells back 1 column
    By Grahamfeeley in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2017, 02:15 AM
  3. Split text into column and select last column and specified where to move the data
    By biroulcontabil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2017, 07:55 AM
  4. Take rows of text and move to into a new column, each column easily identified
    By CATTX01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2015, 03:35 PM
  5. [SOLVED] Move A column text to previous row if duplicate in B column
    By greek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2014, 12:06 AM
  6. [SOLVED] Move Data From One Column to Another based on column headers and Row Text
    By DerbysGal in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-10-2014, 07:21 AM
  7. Replies: 12
    Last Post: 01-08-2014, 11:28 AM

Tags for this Thread

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