+ Reply to Thread
Results 1 to 4 of 4

VBA copy and past to different cell

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-11-2013
    Location
    london
    MS-Off Ver
    Excel 365
    Posts
    270

    VBA copy and past to different cell

    Hi i have this data ( Device:[Hc1 3300 Trunk1] P776 - Mecca Cash Out) in cell d3, what i need is my macro to refer to that cell and bring back the text after the dash and paste to another cell.

    For example, if it had that text in d3 then the macro runs it puts just Mecca Cash Out in D2.

    Thanks in advance

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: VBA copy and past to different cell

    This macro will put the formula into the cell

    Range("D2").FormulaR1C1 = "=TRIM(RIGHT(R[1]C,LEN(R[1]C)-FIND(""-"",R[1]C)))"
    Elegant Simplicity............. Not Always

  3. #3
    Forum Contributor
    Join Date
    08-11-2013
    Location
    london
    MS-Off Ver
    Excel 365
    Posts
    270

    Re: VBA copy and past to different cell

    Im having trouble sloting it in, it needs to go around the bold text, any advice?


     Option Explicit
    
    Sub Break_Report()
    Dim wbTarget As Workbook    'workbook where the data is to be pasted
    Dim wbThis As Workbook      'workbook from where the data is to copied
    Dim strName As String       'target workbook
    Dim cn As String
    Dim shName As String
    Dim wasOPEN As Boolean
        
    shName = Range("D4").Value
        
    Set wbThis = ActiveWorkbook                                     'set to the current active workbook (the source book)
       
    On Error Resume Next
    Set wbTarget = Workbooks("P:\Customer Contact Managers\MI_Resource_planning\A - DAILY\Lateness Trackers\Lateness 2014\Break Lateness.xlsm")           'try to find already open workbook
    
    If Not wbTarget Is Nothing Then
        wasOPEN = True                                              'make a note that it was already open
    Else                                                            'open it if it was closed, put your path in the space noted
        Set wbTarget = Workbooks.Open("P:\Customer Contact Managers\MI_Resource_planning\A - DAILY\Lateness Trackers\Lateness 2014\Break Lateness.xlsm")
    End If
          
    wbTarget.Sheets(shName).Range("xfd1").EntireColumn.ClearContents  'select cell A1 on the target book
    wbThis.Activate                                                 'activate the source book
    Application.CutCopyMode = False                                 'clear any thing on clipboard to maximize available memory
      
    wbThis.ActiveSheet.Range("b2:k100").Copy                         'copy the range from source book
                                                                    'paste the data on the target book ( for just values PasteSpecial xlValues )
    wbTarget.Sheets(shName).Cells(3, Columns.Count).End(xlToLeft).Offset(, 9).PasteSpecial xlPasteAll
     
    Application.CutCopyMode = False                                 'clear any thing on clipboard to maximize available memory
    
    If wasOPEN Then wbTarget.Save Else wbTarget.Close True          'save the target book, close it if it was closed before
     
    wbThis.Close                                              'activate or close the source book again
    
    Set wbTarget = Nothing                                          'clear memory
    Set wbThis = Nothing
     
    End Sub

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: VBA copy and past to different cell

    Advice .. yes... Tell management to stop being idiots...It's not about timing - it's about productivity.

+ 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] Copy row of any cell with date in the past and paste to new sheet
    By jeetamin in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 01-30-2014, 02:07 PM
  2. Replies: 0
    Last Post: 09-07-2013, 04:52 PM
  3. Linking data based on a cell value and copy/past to another worksheet??
    By Tweech in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2012, 01:12 PM
  4. How to copy and past value into empty cell from the next filled cell to the right?
    By Vagueness in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2010, 10:44 AM
  5. Copy&Past Cell Value from one Column to another using VBA
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-29-2009, 01:45 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