Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #109907

Re: Array list writing to an Array of 'scattered cells' ?

Newsgroups microsoft.public.excel.programming
Date 2017-03-13 23:16 -0700
References <8b82fe28-bd0a-45db-80f0-6df276c73c1d@googlegroups.com> <oa7r4v$ra$1@dont-email.me>
Message-ID <07dcf9cd-fbfc-4f16-8f82-9ad1ddab6ff5@googlegroups.com> (permalink)
Subject Re: Array list writing to an Array of 'scattered cells' ?
From "L. Howard" <lhkittle@comcast.net>

Show all headers | View raw


On Monday, March 13, 2017 at 9:24:48 PM UTC-7, GS wrote:
> You do not need this line...
> 
>   Option Base 0
> 
> ..because arrays are zero-based by default!
> 
> One way using arrays:
> Sub Copy_Array()
>   'Do not dimension variants you'll be assigning ranges to!
>   Dim vaSrc, vaTgt, vTmp, n& '(As Long)
> 
>   'Size your ranges as contiguous
>   vaSrc = Range("F1:F5"): vaTgt = Range("A1:E5")
> 
>   'Replace vaSrc data only in vaTgt
>   For n = LBound(vaSrc) To UBound(vaSrc)
>     vaTgt(n, n) = vaSrc(n, 1)
>   Next 'n
> 
>   'Assign vaTgt to its range
>   Range("A1:E5") = vaTgt
> End Sub
> 
> Another way:
> Sub Copy_RngToAreas()
>   Dim vaSrc, rngTgt As Range, n& '(as long type)
> 
>   vaSrc = Range("F1:F5")
>   Set rngTgt = Range("A1,B2,C3,D4,E5")
> 
>   'Replace vaSrc data only in rngTgt
>   For n = LBound(vaSrc) To UBound(vaSrc)
>     rngTgt(n, n) = vaSrc(n, 1)
>   Next 'n
> End Sub
> 
> -- 

Thanks, Garry, those work pretty snappy.

I used the diagonal A1 to E5 to represent what I thought to be 'scattered cells, which are contiguous cells, I think...?

Is there a way to copy F1:F5 cells to cells A1, D5, H9, J6, M11, where these are truly 'scattered'?

And a way to copy say, five truly scattered cells to five other truly scattered cells?

Howard

Back to microsoft.public.excel.programming | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-13 17:28 -0700
  Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-14 00:24 -0400
    Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-13 23:16 -0700
      Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-14 05:38 -0400
        Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-14 08:58 -0700
          Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-14 14:25 -0400
            Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-14 19:03 -0700
              Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-14 22:09 -0400
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-24 01:56 -0700
                Re: Array list writing to an Array of 'scattered cells' ? Claus Busch <claus_busch@t-online.de> - 2017-03-24 10:02 +0100
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-24 08:13 -0700
                Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-24 05:59 -0400
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-24 08:24 -0700
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-24 23:07 -0700
                Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-25 03:08 -0400
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-25 02:16 -0700
                Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-25 05:52 -0400
                Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-25 05:54 -0400
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-25 07:41 -0700
                Re: Array list writing to an Array of 'scattered cells' ? Claus Busch <claus_busch@t-online.de> - 2017-03-25 16:04 +0100
                Re: Array list writing to an Array of 'scattered cells' ? "L. Howard" <lhkittle@comcast.net> - 2017-03-25 11:05 -0700
                Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-25 18:28 -0400
  Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-25 21:29 -0400
    Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-25 22:41 -0400
    Re: Array list writing to an Array of 'scattered cells' ? GS <gs@v.invalid> - 2017-03-28 12:49 -0400

csiph-web