+ Reply to Thread
Results 1 to 3 of 3

Copy from no adjacent cells to adjacent cells

Hybrid View

vkvkcy Copy from no adjacent cells... 09-19-2014, 01:42 AM
Kaper Re: Copy from no adjacent... 09-19-2014, 03:27 AM
vkvkcy Re: Copy from no adjacent... 09-19-2014, 04:06 AM
  1. #1
    Registered User
    Join Date
    09-18-2014
    Location
    China
    MS-Off Ver
    2014
    Posts
    2

    Copy from no adjacent cells to adjacent cells

    Hi there,

    How can I go about getting this done:

    Worksheet A

    Cells A1 B1 C1 D1 E1 F1
    Data 1 "blank" 2 "blank" 3

    Copy FORMULA TO :


    WORKSHEET B[U]

    CELLS F1 G1 H1
    DATA =WORKSHEETA!A1 =WORKSHEETA!C1 =WORKSHEETA!E1


    I tried the ordinary cut and paste from Cells F1 to G1 but instead I get the following

    G1 = 0 (=worksheetA!B1) when what I wanted is to paste the formula worksheetA!C1

    I am wondering if there is any way I can achieve this thru VB or some excel function.

    Anyway, I tried to use VB to achieve this and here is my code :

    Sub ACTest()
    Dim A As String
    ActiveCell.Select ' WorksheetA! CellA1
    Dim B As Integer
    A = ActiveCell.FormulaR1C1
    Dim n As Integer



    n = 1
    For n = 1 To 10
    B = 9 + n
    ActiveCell.Select
    'Range("E69").Select
    'Range("E69").FormulaR1C1 = "=WorksheetB!R[25]C[" & B & "]"
    ActiveCell.Formula = "=Outflow!R[25]C[" & B & "]"
    ActiveCell.Offset(0, 1).Select
    Next n

    This works ok and enable me to paste the formulas onto worksheet b while without skipping any cells in B.
    So my question is

    1) How can I display the formula - ActiveCell.FormulaR1C1. (What I dis now was put A in a message box and copy it into the code. (definitely a silly way to do it)

    2) After displaying it which is = WorksheerA!R[25]C[10] , how can I extract the vale of C i.e. the col number such that I can input into the formula :
    B= C + n.

    I really hope I am making sense. Spend many hours searching the web and trying to figure this out so any help will be really appreciated. I think this is a common problem
    and there is likely to be a simple solutions.

    Thank you all in advance.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Copy from no adjacent cells to adjacent cells

    1) please edit your post and aply code tags. See why and how: http://www.excelforum.com/forum-rule...rum-rules.html
    2) try something similar to:
    Sub ACTest2()
    'first cell to be filled with formula is active
    'this and next cells will be filled with formula refering only to non-blanks in Outflow sheet starting with A25
    Dim n as long
    For n = 1 To 10
      if sheets("Outflow").cells(25,n)<>"" then
          ActiveCell.Formula = "=Outflow!R25C" & n  'use [] if you want relative addresses
          ActiveCell.Offset(0, 1).Select
      end if
    Next n
    Last edited by Kaper; 09-19-2014 at 03:37 AM. Reason: commented on relative addresses
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    09-18-2014
    Location
    China
    MS-Off Ver
    2014
    Posts
    2

    Re: Copy from no adjacent cells to adjacent cells

    Hi there,

    thank you so very much for your reply. I will give it a try.

    Also this is the first time I am writing to any forums so not too sure about the rules. Apologies.

    Anyway yes, have to edit my post (some typo error ) and tag it. Wiil find out how. Any assistance will be well appreciated.

    Cheers!

+ 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: 3
    Last Post: 07-16-2014, 03:24 PM
  2. [SOLVED] Concatenating adjacent and non adjacent cells depending on entries
    By TBHusker84 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2013, 10:27 AM
  3. Replies: 7
    Last Post: 12-04-2012, 06:23 AM
  4. Replies: 3
    Last Post: 07-30-2012, 11:20 AM
  5. How do I fill (copy) nonadjacent cells to adjacent cells?
    By BuckyGeorge in forum Excel General
    Replies: 2
    Last Post: 12-22-2005, 12:25 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