+ Reply to Thread
Results 1 to 10 of 10

copy cells but miss blanks

Hybrid View

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: copy cells but miss blanks

    The technique still works, you just didn't mention the range included both formulas and constants. Like so:

    Sub Copy_address3()
    Dim RNG As Range
    
    Set RNG = Union(Range("B5:E10").SpecialCells(xlCellTypeConstants, 2), _
                     Range("B5:E10").SpecialCells(xlCellTypeFormulas, 2))
    RNG.Copy
    Sheets("CERTIFICATE").Range("A1").PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    
    End Sub

    Notice I've not done any "selecting" like your other macro show. It's not necessary to bring sheets up onscreen or selecting cells before issuing action commands to them. Just properly address those ranges with complete references and the selecting goes away.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  2. #2
    Forum Contributor
    Join Date
    02-08-2006
    Location
    UK
    MS-Off Ver
    2013
    Posts
    204

    Re: copy cells but miss blanks

    Oh thank you so much - it's been giving me a headache for yonks.

    I take on board what you said about selecting - it's just that the only things I know about VBA are what I pick up from here and jiggling about with the code until I get what's needed (or at least get rid of the errors!).

    Thanks again

+ 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