Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default variable paste or fill range

Using VBA I need to paste a named formula "BinTest" into a range of
cells in a column. Starting at A37. The length of the range of cells is
dependant upon the value of another name "Range". I want this to
fire when the worksheet is selected if that is possible.

I think I need to use a fill function and somehow check the value of
"Range" and then say fill down from A37 but I have no idea where to
start.

Any help, code examples, etc. will be appreciated

Robert

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default variable paste or fill range

Here some code that might help start you off. This code takes the named
range "Range" in sheet 1 and when sheet 2 is activated the named range
"Range" is muliplied by 10 and placed in sheet 2 in Column A starting
at row 37 filling down.

Place this code in the "Sheet2" section in the Visual Basic Editor(VBE)

Private Sub Worksheet_Activate()
Dim BinTest As Long
Dim BRange, CRange, i, n As Integer
BRange = 37
CRange = Worksheets("Sheet1").Range("Range").Count
n = 1
For i = BRange To (BRange + (CRange - 1)) Step 1
Worksheets("Sheet2").Cells(i, 1).Value = _
Worksheets("Sheet1").Range("Range").Cells(n, 1).Value * 10
n = n + 1
Next
End Sub

Hope this get you started

Sandy

wrote:
named foumula "BinTest":
=IF(COUNT(BINFilStart:A)<INDIRECT($C$114&"BinCount "&$D$114),A113+INDIRECT($C$114&"BinSize"&$D$114)," ")

Thanks
Robert

Sandy wrote:
What is the formula for "BinTest"?

wrote:
Using VBA I need to paste a named formula "BinTest" into a range of
cells in a column. Starting at A37. The length of the range of cells is
dependant upon the value of another name "Range". I want this to
fire when the worksheet is selected if that is possible.

I think I need to use a fill function and somehow check the value of
"Range" and then say fill down from A37 but I have no idea where to
start.

Any help, code examples, etc. will be appreciated

Robert


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default variable paste or fill range

Sandy, I just did a quick tes and I should be able to adapt and build
from this.
Thank you very much for your effort
Robert


Sandy wrote:
Here some code that might help start you off. This code takes the named
range "Range" in sheet 1 and when sheet 2 is activated the named range
"Range" is muliplied by 10 and placed in sheet 2 in Column A starting
at row 37 filling down.

Place this code in the "Sheet2" section in the Visual Basic Editor(VBE)

Private Sub Worksheet_Activate()
Dim BinTest As Long
Dim BRange, CRange, i, n As Integer
BRange = 37
CRange = Worksheets("Sheet1").Range("Range").Count
n = 1
For i = BRange To (BRange + (CRange - 1)) Step 1
Worksheets("Sheet2").Cells(i, 1).Value = _
Worksheets("Sheet1").Range("Range").Cells(n, 1).Value * 10
n = n + 1
Next
End Sub

Hope this get you started

Sandy

wrote:
named foumula "BinTest":
=IF(COUNT(BINFilStart:A)<INDIRECT($C$114&"BinCount "&$D$114),A113+INDIRECT($C$114&"BinSize"&$D$114)," ")

Thanks
Robert

Sandy wrote:
What is the formula for "BinTest"?

wrote:
Using VBA I need to paste a named formula "BinTest" into a range of
cells in a column. Starting at A37. The length of the range of cells is
dependant upon the value of another name "Range". I want this to
fire when the worksheet is selected if that is possible.

I think I need to use a fill function and somehow check the value of
"Range" and then say fill down from A37 but I have no idea where to
start.

Any help, code examples, etc. will be appreciated

Robert




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default variable paste or fill range

so far my adaptation is:

Private Sub Worksheet_Activate()
Dim BinTest As Long
Dim BRange, CRange, i, n As Integer
Dim Htestc As Worksheet

'row count for target location
BRange = 114

'establish target range size based on named range "Range"
CRange = Worksheets("BinSize").Range("Range").Value
n = 1

'paste named formula "BinFill" into range of cells
' starting at 114 with size established by "Range"
For i = BRange To (BRange + (CRange)) Step 1
ActiveSheet.Cells(i, 1).Value = _
ActiveSheet.Names("BinFill").Cells(n, 1).Value
n = n + 1
Next
End Sub

I get the error "Object doesnt support this method..."
I think it means I cant use .names with Activesheet, I had the same
error with Worksheet.

this is just a matter of me not understanding what works with what and
the help info on the name object is kind of lame.

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 Copy and Paste a variable range IK Excel Programming 1 August 29th 06 09:04 PM
Copy/paste range variable between workbooks Jim73 Excel Programming 2 January 14th 05 08:17 AM
Fill a listbox with data from variable range Al Excel Programming 2 August 10th 04 07:05 AM
Macro to Paste to a Variable Range - HELP Brandon - Excelinator Excel Programming 1 August 7th 04 10:04 PM
Paste a Range from a variable Al[_11_] Excel Programming 3 October 28th 03 06:04 PM


All times are GMT +1. The time now is 10:13 AM.

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"