+ Reply to Thread
Results 1 to 12 of 12

Pasting into Visible cell range only - VBA?

  1. #1
    Registered User
    Join Date
    10-09-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    49

    Angry Pasting into Visible cell range only - VBA?

    Hi!

    Trying to figure out how to take consecutive data from one tab and paste it into visible cells only on another report. My Kutools trial is over and I used to be able to do so by using Paste to visible Range.

    Basically I need consecutive data to paste into every 4th cell but right now it's taking the first row of data and repeating it until the end of my range in which the balance of the rows is then pasted consecutively.

    I've tried copying and then choosing Find & Select - Go to Special - Visible Cells only then pasting and no luck as it does what I mentioned above.

    Help! Thanks
    Last edited by AliGW; 08-09-2017 at 09:47 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,805

    Re: Pasting into Visible cell range only

    You can't, I'm afraid. Maybe pay for KuTools? It's not that expensive and it does have quite a few really useful short cuts. Your only other option is a small VBA routine.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-09-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    49

    Re: Pasting into Visible cell range only

    Thanks Ali!
    That's what I was thinking but thought I'd take a chance and ask. I figured if Kutools can do it someone may know how?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,805

    Re: Pasting into Visible cell range only

    Someone will. I'll move this to the VBA section for you.

  5. #5
    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,620

    Re: Pasting into Visible cell range only - VBA?

    Try such simple code:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Kaper; 08-09-2017 at 10:26 AM. Reason: added if i <= OutRng.Cells.Count Then to limit copying from below shown range - not changed in attachment
    Best Regards,

    Kaper

  6. #6
    Registered User
    Join Date
    10-09-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    49

    Re: Pasting into Visible cell range only - VBA?

    Hi Kaper,

    Sorry I'm not so tech savvy. Where do I plug this code in?

  7. #7
    Registered User
    Join Date
    10-09-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    49

    Re: Pasting into Visible cell range only - VBA?

    Actually I think I got it. I downloaded your file and it now shows in my Macros.
    Thank you so much!

  8. #8
    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,620

    Re: Pasting into Visible cell range only - VBA?

    Short instruction:
    Open your file
    Press Alt+F11 Visual Basic Editor will open
    Press Alt+I, M New module will be created (shall be visible as open editor window at upper-right part
    Paste code there
    Close VBE (you will return to your workbook)
    Save your file in macro-enabled format (xlsm)
    Ready!

  9. #9
    Registered User
    Join Date
    10-09-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    49

    Re: Pasting into Visible cell range only - VBA?

    Hi Kaper...wondering if you can alter the code you had created so that it works on my new report.

    I tried to run it but it's only adding every 15th account name from my pivot table. I need it to add my account's consecutively in every 37th cell. Rows between each account cell is = to 36.

    Sub CopyDataToVisibleCOMPS()
    Dim rng As Range, InputRng As Range, OutRng As Range, i As Long
    Set InputRng = Application.InputBox("Range with data", Type:=8)
    Set OutRng = Application.InputBox("Output range", Type:=8).SpecialCells(xlCellTypeVisible)
    If InputRng.Cells.Count > OutRng.Cells.Count Then
    MsgBox "Sorry not enough cells to paste data from " & InputRng.Address
    Else
    For Each rng In OutRng
    i = i + 1
    rng.Value = InputRng.Cells(i).Value
    Next rng
    End If
    End Sub
    Attached Files Attached Files

  10. #10
    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,620

    Re: Pasting into Visible cell range only - VBA?

    Two comments -
    1) I believe it's different problem than one originaly solved. If I'm wrong, and you just want to have headers from second sheet copied to dark merged cells in first sheet then the code needs some tuning to deal with merged cells. for instance this shall do:
    Please Login or Register  to view this content.
    of course you shall show only first level of conspect in sheet 1 - make only dark cells visible

    2) since it's a year of inactivity you probably forgot one of our rules:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

  11. #11
    Registered User
    Join Date
    10-09-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    49

    Re: Pasting into Visible cell range only - VBA?

    Hi Kaper,

    I tried to adjust thread but can't find EDIT for the life of me. Also, still not quite clear on adding code tags.

    Finally, is there a way to make that code universal, in other words, I can use it on any report where I want to copy a pivot table list consecutively and past visible onto another tab.
    See sample report attached. I tired using the macro on this one but as I mentioned above it keeps pasting the every 15th account from the pivot table. Someone had created
    a formula but it causes the report to take super long to calculate making updating this report very time consuming.

    Does the original code below show an amount of rows? Not a VBA expert so haven't been able to understand how this runs.

    Please Login or Register  to view this content.

    Thanks.
    Attached Files Attached Files

  12. #12
    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,620

    Re: Pasting into Visible cell range only - VBA?

    You can't edit because the thread is a year+ old.

    My suggestion is: if its used in your daily (yearly :-P) routine, why not pay modest price for KuTools?

    Other possibility: start a new thread (may be with link to this one) with precise description and good, representative but small sample attached.

+ 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. Pasting Into Visible Cells Only
    By Zach Boyer in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-15-2016, 09:40 AM
  2. Select visible range and add page break after every 20th visible cell
    By tuc47285 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2015, 01:18 AM
  3. Pasting into only visible cells
    By Cheeseburger in forum Excel General
    Replies: 6
    Last Post: 03-28-2013, 02:49 PM
  4. [SOLVED] Copy/Pasting Values from visible cells (using autofilter) to visible cells
    By evakotsi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 07:49 AM
  5. Pasting to Visible Cells
    By Trying in forum Excel General
    Replies: 0
    Last Post: 01-24-2010, 08:39 PM
  6. pasting to visible cells only
    By snoozy71 in forum Excel General
    Replies: 1
    Last Post: 03-22-2009, 12:26 AM
  7. [SOLVED] Pasting in visible cells only
    By Howieben in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-04-2006, 04:00 PM

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