Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Excel VBA, dynamic references

I would like the macro to copy a static range and paste it in spesific
rows depending on counter-formulas.

I have one counter in cell av1, at the time giving the result 331.

So for pasting in one cell, I change the recorded VBA-string:
Range("AV331").Select

into the following that works fine:
Range("AV" & Range("Av1").Value).Select

My problem is that I also have a counter in aw1, at the time giving
the result 333. So what I want to do is to paste in a range, not in a
single cell:
Range("AV331:AV333").Select

How do I do this? Tried:
Range("AV" & Range("Av1").Value:"AV" & Range("Av1").Value).Select

but did not work. Any ideas?

Brgds,
Harald
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Excel VBA, dynamic references

hi
not entirely sure what you trying to do but here is some sample code to
select a range.....

Dim r As Range
Set r = Range("A1:C1")
r.Select

regards
FSt1

" wrote:

I would like the macro to copy a static range and paste it in spesific
rows depending on counter-formulas.

I have one counter in cell av1, at the time giving the result 331.

So for pasting in one cell, I change the recorded VBA-string:
Range("AV331").Select

into the following that works fine:
Range("AV" & Range("Av1").Value).Select

My problem is that I also have a counter in aw1, at the time giving
the result 333. So what I want to do is to paste in a range, not in a
single cell:
Range("AV331:AV333").Select

How do I do this? Tried:
Range("AV" & Range("Av1").Value:"AV" & Range("Av1").Value).Select

but did not work. Any ideas?

Brgds,
Harald

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Excel VBA, dynamic references

Hi,

I want the range AV331:AV333 to be dynamic, meaning the rownumbers
should be based on the result in the counter-cells AV1 and AW1.

In your example, Range("A1:C1") will always be selected as it is not
connected to a dynamic cell if I am not wrong.
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Excel VBA, dynamic references

Dear

You must change the code to:
Range("AV" & [Av1]&":AV" & [Av1]).PasteSpecial xlPasteValues

[] Is Evaluate Method
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Excel VBA, dynamic references

On 26 Nov, 11:58, Nattasiray
wrote:
Dear

You must change the code to:
Range("AV" & [Av1]&":AV" & [Av1]).PasteSpecial xlPasteValues

[] Is Evaluate Method



Thanks for the reply but still gets error from VBA. What do you mean
by [] Is Evaluate Method? Do I need to put that in the string?

Brgds,
Harald


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6,582
Default Excel VBA, dynamic references

Don't be trapped into using []. It is a handy shortcut, but it's more useful
to keep the full referencing of the object and its methods in the code:

Range("AV" & Range("AV1").Value & ":AV" & Range("AV1").Value).Select

although this is a one-celled reference the way it is written. Perhaps you
mean a variation like one of these:

Range("AV" & Range("AV1").Value & ":AV" & Range("AV2").Value).Select

Range("AV" & Range("AV1").Value & ":AZ" & Range("AV1").Value).Select

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


wrote in message
...
On 26 Nov, 11:58, Nattasiray
wrote:
Dear

You must change the code to:
Range("AV" & [Av1]&":AV" & [Av1]).PasteSpecial xlPasteValues

[] Is Evaluate Method



Thanks for the reply but still gets error from VBA. What do you mean
by [] Is Evaluate Method? Do I need to put that in the string?

Brgds,
Harald



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Excel VBA, dynamic references

Tthat worked fine.

And yes, I misprinted it to be a one-celled reference in my original
question. It now is as follows:
Range("AV" & Range("AV1").Value & ":AV" & Range("AW1").Value).Select

Thanks!

Harald
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
Dynamic formulas including worksheet references lars22222 Excel Worksheet Functions 1 July 26th 05 02:33 PM
dynamic cell references excel novice Excel Worksheet Functions 2 July 12th 05 02:59 PM
Dynamic references in diagram source data? Olzki Excel Discussion (Misc queries) 0 March 1st 05 08:33 AM


All times are GMT +1. The time now is 07:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"