Macro : Filling Data Into Multiple Cell and Different Sheets At Once

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all....
i need your help in vba/macro filling in several cell and several sheets
this code work but only in 1 cell , how to adding in the other cells...

Code:
Sub PopulateMacro()

    Dim cell As Range
    Dim i As Long
    
    Application.ScreenUpdating = False
    
    For Each cell In Sheets(1).Range("A1:A40")
        i = cell.Row + 1
        Sheets(i).Range([COLOR=#ff0000]"H13[/COLOR]") = cell.Value
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub[CODE]

i want this code work too in my target e.g cell [COLOR=#ff0000]H13[/COLOR], [COLOR=#ff0000]J13[/COLOR], L13, etc...

i try modify Sheets(i).Range([COLOR=#ff0000]"H13[/COLOR]",[COLOR=#ff0000]"J13"[/COLOR]) = cell.Value but not work

any help greatly appreciated..

.sst
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Please explain in words what your wanting.

And give all sheet names.

You only said:
i need your help in vba/macro filling in several cell and several sheets

What cells and what sheets would help.
 
Upvote 0
my data in sheet1 in range A1:A40 and my target as expected result in other sheets (several sheets) exactly in cell H13,J13,L13.
before it, my code as well done but work ONLY in cell H13..
i want work too in cell H13,J13,L13...
 
Upvote 0
I cannot tell the script to do this on several sheets.

I need sheet names or something like sheet(1) to sheets(5)



This should do what you want on Sheet(1)

Code:
Sub PopulateMacro()
'Modified  8/18/2018  11:48:19 PM  EDT
Application.ScreenUpdating = False
Dim r As Range
Dim x As Long
x = 8
    For Each r In Sheets(1).Range("A1:A40")
        Sheets(1).Cells(13, x).Value = r.Value: x = x + 2
    Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
hi...i think work but not fully my expected....
your code only work in the same sheet but for another sheet not work....
 
Last edited:
Upvote 0
Thats why I asked you what other sheet???

You have not said what other sheets.
 
Last edited:
Upvote 0
If you want this to work in all the sheets in your workbook

And each sheet has a different set of values in Range("A1:A40")

Try this:

Code:
Sub PopulateMacro_All_Sheets()
'Modified  8/19/2018  7:40:53 AM  EDT
Application.ScreenUpdating = False
Dim r As Range
Dim x As Long
Dim i As Long
For i = 1 To Sheets.Count
    With Sheets(i)
        x = 8
        For Each r In .Range("A1:A40")
            .Cells(13, x).Value = r.Value: x = x + 2
        Next
    End With
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,247
Members
448,879
Latest member
oksanana

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