+ Reply to Thread
Results 1 to 9 of 9

Copying a cellvalue, and use it in VBA?

  1. #1
    Registered User
    Join Date
    02-27-2022
    Location
    Norway
    MS-Off Ver
    Office365 2022
    Posts
    8

    Copying a cellvalue, and use it in VBA?

    Hi, i were wondering how i can copy a numbervalue from B4 in sheet called Dimensjonerende kriterier, and use this value to specify a starting point for a copy command
    i'm using match formula in B4 to get the Y-reference to were that is, and going to copy in x-y position from that starting point

    below is my VBA so far.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Copying a cellvalue, and use it in VBA?

    I think you need to explain a little more for example
    in B4 is the value 7
    so in column G of the Ark2 sheet I wish to paste in G7

    Please Login or Register  to view this content.
    unless it is similar logic for the cell you are copying from Range("A" & startrow).Copy Worksheets("Ark2").Range("G5") it is not quite clear

  3. #3
    Registered User
    Join Date
    02-27-2022
    Location
    Norway
    MS-Off Ver
    Office365 2022
    Posts
    8

    Re: Copying a cellvalue, and use it in VBA?

    in Cell B4 i have a match formula that checks the name in B3 with the list in "Ark1" Cell A:A
    and returns a numbervalue.
    i need the code to use this value when copying from a location in Ark2
    added my excelsheet if this helps-


    Attachment 770386
    Attachment 770387
    Attached Files Attached Files
    Last edited by AndreasWalseng; 02-28-2022 at 06:48 AM.

  4. #4
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Copying a cellvalue, and use it in VBA?

    whats wrong with post 2?

  5. #5
    Registered User
    Join Date
    02-27-2022
    Location
    Norway
    MS-Off Ver
    Office365 2022
    Posts
    8

    Re: Copying a cellvalue, and use it in VBA?

    read the first statement as a request to clarify what i ment and thought the code was just a quote . sorry works great, however one question.
    Please Login or Register  to view this content.
    how can i add a boundry to the "G" & startrow? normaly you can define a range like A1:B6.
    as i need to copy from
    Attachment 770398

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Copying a cellvalue, and use it in VBA?

    Your attachment is not valid when i try to open it so a bit in the dark, so the below is a guess. Something along these lines

    if you know the columns wont change but the rows will
    Range("B" & startrow &":G"& endrow) for example

    or something like Range(Cells(5, 6), Cells(7, 8)).Select will select f5:h7 it can be replaced with variables

    Range(Cells(startrow, startcolumn ), Cells(endrow, endcolumn)).Select

    you can call the variables by whatever names you wish

  7. #7
    Registered User
    Join Date
    02-27-2022
    Location
    Norway
    MS-Off Ver
    Office365 2022
    Posts
    8

    Re: Copying a cellvalue, and use it in VBA?

    Thanks sir, it works like a charm.
    however i have another issue, whenever i copy with VBA the index/match formula goes I/T? what is the reason for this?
    Attachment 770424

  8. #8
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Copying a cellvalue, and use it in VBA?

    Your attachments are invalid. the post 3 with a spreadsheet is ok, but everything that says attachment doesn't open. So I can not offer any help as I can't see anything!

    Why not attach as post 3 and refer to the specific cells that are causing a problem.
    When copying do you wish for the formula to be copied or just its value?

  9. #9
    Registered User
    Join Date
    02-27-2022
    Location
    Norway
    MS-Off Ver
    Office365 2022
    Posts
    8

    Re: Copying a cellvalue, and use it in VBA?

    Got it working, thanks for your help sir!
    Last edited by AndreasWalseng; 03-02-2022 at 04:07 PM.

+ 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] Button appers with cellvalue
    By Gamla kläder in forum Excel General
    Replies: 10
    Last Post: 10-24-2018, 10:45 AM
  2. [SOLVED] Change cellvalue with another cell
    By hep in forum Excel General
    Replies: 3
    Last Post: 09-06-2016, 04:22 AM
  3. Use hyperlink as cellvalue
    By WilVerstappen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2016, 04:09 PM
  4. [SOLVED] If cellvalue = 0, then take the cell value to the left
    By mariec_06 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-02-2016, 07:03 AM
  5. [SOLVED] Change Cellvalue to a Formula
    By turist in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2014, 10:17 AM
  6. [SOLVED] CellValue = TextBox6 + TextBox4(*7) VBA
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 08-15-2013, 12:38 PM
  7. [SOLVED] Returning last cellvalue in row
    By Lv27 in forum Excel General
    Replies: 6
    Last Post: 08-21-2012, 07:28 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