+ Reply to Thread
Results 1 to 2 of 2

VBA: Marco to run on cell change

  1. #1
    Registered User
    Join Date
    06-28-2017
    Location
    UK
    MS-Off Ver
    2007
    Posts
    37

    VBA: Marco to run on cell change

    Hi Everyone,

    I have a Marco which runs on a cell and uses text to column to split it twice. I have the below formula run on a button. However, I'd like it to run when cell J15 has changed. Would someone kindly advise on how this might look, please?


    ++++

    Sub PostcodeMover()
    '
    ' Macro3 Macro
    '

    '
    Selection.TextToColumns Destination:=Range("AC42"), DataType:=xlFixedWidth _
    , FieldInfo:=Array(Array(0, 1), Array(2, 1)), TrailingMinusNumbers:=True
    Selection.TextToColumns Destination:=Range("AC41"), DataType:=xlFixedWidth _
    , FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(2, 1)), TrailingMinusNumbers _
    :=True
    Range("AC27:AC36").Select
    Selection.Copy
    End Sub

    ++++

    I'm sure it's a really easy fix but I can't say I'm the best with VBA coding etc
    Last edited by AlexShip; 07-04-2019 at 10:45 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA: Marco to run on cell change

    Hi,

    What's in J15? A formula or a manual entry. If a formula you need to find the precedent (manually changed) cell that causes J15 to change. Then in the Sheet that contains the precedent cell use the Worksheet_Change event macro. Somethig like the following - untested since you've not supplied a workbook


    Please Login or Register  to view this content.
    Obviously change the Sheet and range references. And simularly for yor second text to columns code.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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. Replies: 1
    Last Post: 06-13-2019, 07:34 PM
  2. [SOLVED] Help with Worksheet Change command to change Cell value without pressing Enter key
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2016, 12:30 PM
  3. Worksheet change event with multiple column cell value change
    By borgyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-29-2015, 11:53 AM
  4. [SOLVED] Change On_Open macro to a cell change in a range of cells
    By davidpierce in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-27-2015, 02:46 PM
  5. If range value change, active cell equal date and time of change.
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2015, 02:43 PM
  6. auto change cell formula on condition of worksheet change in other cells
    By futurejock in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-01-2009, 12:11 AM
  7. [SOLVED] making copied cells change with change in original cell
    By Jennifer Mcdermeit in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2006, 11:58 AM

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