+ Reply to Thread
Results 1 to 2 of 2

Using the variable x, copying the value of the cell to the right using offset.

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Using the variable x, copying the value of the cell to the right using offset.

    Hi,

    This is my very first VBA post so I apolgise in advance if I miss something vital. I've spent a little while looking at forums but cannot find many posts where variabes are used alongside offsets. I need help in VBA completing the following steps which is activated by the click of a button.

    - Find the value of x (used as a counter) within the range B5:B11 on the sheet called "Site Costs".
    - Once the value of x is found in the range B5:B11, offset one cell to the right to obtain the Primary Value for x.
    - Paste the Primary Value into the cell B13. (temporary test as I aim to complete the below).

    - Copy the value from the Primary Value cell back to the main "Customer Site and Core Costs" sheet in the relevant x row.
    - Paste the Primary value into the Primary Circuit Cost field which has an offset of six to the right.

    Its the block of code in between the >>>>>>>>>>> <<<<<<<<<<<<<<< that is causing the problems for me as I have tested the loop already and it works.

    Please Login or Register  to view this content.

    Any advice would be appreciated.

    Thanks in advance


    Moderator Edit:

    Welcome to the forum, Andysmith1983.

    Please notice that code tags have been added to your post. The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.
    Last edited by Cutter; 09-21-2012 at 10:14 AM. Reason: Added code tags

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Using the variable x, copying the value of the cell to the right using offset.

    Hi, Andysmith1983,

    you either have to loop through the range in the other sheet as well or use Application.Match to find the value. The change to your code is untested:
    Please Login or Register  to view this content.
    An example how to use Application.Match:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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