How to copy and paste a range of cells from another worksheet depending on predefined indices in VBA | بلاگ

How to copy and paste a range of cells from another worksheet depending on predefined indices in VBA

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

I'm struggling to see why one can't do the following with respect to a block of a worksheet cell. (It works when I do a similar thing for other instances). Ultimately I'm trying to paste a formula (that calls a different sheet), across a range in my "Input" sheet.

The formula should read...

=+D14*(1+Sheet1!$D$4)

For the first cell, and it should change automatically for all other cells in the range.

Here is a simplified version of my code to get an idea as to what I've tried so far... Thanks:

Option Explicit

Sub PasteTest()
Dim ws(1) As Object

Set ws(1) = Worksheets("Input")

Dim idx_1, idx_2, idx_3 As Long 'no of cells

idx_1 = 76
idx_2 = 8
idx_3 = 3 + idx_2 + idx_1

ws(1).Range("D" & idx_3 & ":DR" & idx_2).Formula "=D14*(1+Sheet1!" & Chr(36) & "D" & Chr(36) & "4)"

End Sub
asked 36 secs ago
SadMrFrown

...
نویسنده : استخدام کار بازدید : 0 تاريخ : چهارشنبه 14 شهريور 1397 ساعت: 5:06