Something New or Something Old

jvoss

Board Regular
Joined
Jun 13, 2015
Messages
76
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Good day all, doing some testing on vba and found something odd.
here is the setup
Dim N As Long
Dim ws As Worksheet: Set ws = Worksheets("Sheet2")
'N is lastrow on sheet 1, A column
ws.Range("A4:A" & N).FormulaR1C1 = "=LIST!R[1]C[64]" 'BM
ws.Range("B4:B" & N).FormulaR1C1 = "=LIST!R[1]C[8]" 'J

now i add a new row.

ws.Range("C4:C: & N).FormulaR1C1="=LIST!R[1]C[9]" 'k

however it will not show the data in sheet1!K1 it show the data in sheet1!L1.....
WHY.......
if i do,
ws.Range("C4:C: & N).FormulaR1C1="=LIST!R[1]C[8]" 'k
it shows data in sheet1!K1.....
WHY.......

what i have found out by testing you see that if i subtract the column count from column wanted i get the right data i'm looking for.
Why is that.

example to explain if unclear if( sheet2!C = column 3 and Column sheet1!K is 11) then in order to get data from k on sheet 1 to column c in sheet 2 i have to subtract 3-11 i get 8 then i have to use *** ws.Range("C4:C: & N).FormulaR1C1="=LIST!R[1]C[8]" 'this r1c8 =sheet1! K1 ** in order to get the right dataset..
should this not be ws.Range("C4:C: & N).FormulaR1C1="=LIST!R[1]C[11]" ' this r1,c11 =sheet1! K1.... ?????

I'm totally confused..


** edited to correct sheet reff. 1213pm 9/15/24
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
R1C9 is the ninth column (ie cell I1) regardless of where the formula is.
R[1]C[9] is the ninth column to the left of the formula & one row below, so if the formula is in C4 it will give L5
 
Upvote 1
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,112
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top