Search code examples
excelexcel-2010excel-2007vba

Refer the attachment Excel Spreadsheet please send me a solution


The attached image shows that Cell F52 shows the number 6, which is variable from 1 to 200 and cell N77 shows the value 1663 RS., As the number varies 1 to 200 bill money also changed. I need to make list individuals bill amount in 200 rows and 2 columns.

Example:

1 200
2 600
3 ..
4 ..
5 ..
6 1663 
7 ..
etc 

Please help me macro code for this, I am new to macro.

enter image description here


Solution

  • Your question is extremely vague, but if I understand it correctly then the following would work as long as you add another Sheet in the case below that sheet is called "Result":

    Sub foo()
    Dim ws As Worksheet: Set ws = Sheets("Sheet1") 'The sheet where you have to enter your data
    Dim ws2 As Worksheet: Set ws2 = Sheets("Result") 'The sheet where the results will go
    For i = 1 To 200
        ws.Range("F52").Value = i 'change the value of F52 from 1 to 200 in a loop
        ws2.Cells(i, 1).Value = i 'write the value in the sheet Result
        ws2.Cells(i, 2).Value = ws.Range("N77") 'get the calculated value from N77
    Next i
    End Sub