• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA macro to display table for values mentioned in cell A2 to cell B2 (if the values are changed in cell A2 and B2 then table should be generate)

AmitSingh

Member
Hi,

Want to generate or display table for values entered in cell A2 to B2 cell. If the values of A2 and B2 cell change then table should be generated.

Tried with below code but didn't get desired output.

Code:
Option Explicit

Sub table()

Dim i As Integer
Dim j As Integer

For i = 2 To 4
    For j = 2 To 4
    Range("K4").Activate
    ThisWorkbook.Sheets("Table").Cells(j, i).Value = j * i
    Next j
Next i

End Sub

Thanks in advance for help.

Thank you!!

Regards,
Amit Singh
 

Attachments

  • Table Generate.xlsm
    11 KB · Views: 4
AmitSingh
Was there some kind of clear rule with Your given output?
... if was ... then I had to skip it ... where is Your named table?
One sample without any table...
 

Attachments

  • Table Generate.xlsb
    17.9 KB · Views: 2
You can do this with a formula.
If you have the SEQUENCE function available to you:
in cell C4 (say):
Code:
=INDEX(SEQUENCE(B2-A2+1,1,A2),(INT((SEQUENCE((B2-A2+1)*10)-1)/10)+1))*(MOD((SEQUENCE((B2-A2+1)*10))-1,10)+1)
and if you have the LET function too:
Code:
=LET(from,A2,a,B2-from+1,size,10,b,SEQUENCE(a*size)-1,INDEX(SEQUENCE(a,,from),(INT(b/size)+1))*(MOD(b,size)+1))
In this last you only need 3 references/values (A2, B2 & 10).
 

Attachments

  • Chandoo47781Table Generate.xlsx
    12.5 KB · Views: 0
Last edited:
Back
Top