Help in VBA

Meko1

New Member
Joined
Oct 20, 2020
Messages
44
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
Function Filling_Summary_Sheet()

  Sheet1.Range("B4") = ActiveSheet.Range("C6")
  Sheet1.Range("C4") = ActiveSheet.Range("B7")
  Sheet1.Range("D4") = ActiveSheet.Range("B12")
  Sheet1.Range("E4") = ActiveSheet.Range("F7")
  Sheet1.Range("F4") = ActiveSheet.Range("I30")
End Function


This is my code and I am trying to add the following:
Imagine my ActiveSheet is called "paid1"; After running it, I will move on the next sheet in excel which is called "paid2" and want to run same macro, just Cell Data now instead of B4, C4, D4, E4, F4 to go in B5, C5,D5, E5 F5. And this to happen for 500Activesheets or from "paid1" to "paid500".

if the provided info is not enough let me know

Thanks in advance.
 
Last edited by a moderator:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Do your sheets go in order from left to right starting at the leftmost sheet?
 
Upvote 0
ActiveSheets start from sheet6. and goes from left to right in order
 
Upvote 0
And is Sheet6 the 6th sheet from the left?
 
Upvote 0
it is like this.
Data needs to go from "Basic infos" into summary
 

Attachments

  • Screenshot 2020-11-07 103313.png
    Screenshot 2020-11-07 103313.png
    5.4 KB · Views: 7
Upvote 0
Please answer the question, I am not coding based a partial image of your workbook.
 
Upvote 0
Try the code below (I have only made it a Sub rather than a function as it is easier to test, don't know why you had it as a function to start with though as you aren't feeding it any parameters).

VBA Code:
Sub Filling_Summary_Sheet()
    Dim i As Long
    Application.ScreenUpdating = False

    For i = 6 To 505
        With Sheets(i)
            Sheet1.Cells(.Index - 2, "B") = .Range("C6")
            Sheet1.Cells(.Index - 2, "C") = .Range("B7")
            Sheet1.Cells(.Index - 2, "D") = .Range("B12")
            Sheet1.Cells(.Index - 2, "E") = .Range("F7")
            Sheet1.Cells(.Index - 2, "F") = .Range("I30")
        End With
    Next
    
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,616
Messages
6,125,860
Members
449,266
Latest member
davinroach

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