• 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.

Help Fix My Code

nothumbs

New Member
Looking to fix code to help with a problem. I have 200 worksheets and I want to put certain info from each cell in a column to a specific cell in the worksheets.

Code:
Sub t()
Dim c As Range, i As Long
i = 1
For Each c In Sheets(1).Range("A1", Sheets(1).Cells(Rows.Count, 1).End(xlUp))
i = i + 1
Sheets(i).Range("C4") = c.Value
Next
End Sub

I keep getting a bug at Sheets(i).Range("C4") = c.Value because it is out of range. It also seems to grab a row info and not a column.

Please help guys. Thank you.


▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !
 

Attachments

  • things.xlsx
    9.4 KB · Views: 2
Should your code be:

Code:
Sub t()
Dim sh As Worksheet
Dim c As Integer
For Each sh In Worksheets
    Sh.Range("C4") =sh.Range("A" & Rows.Count).End(xlUp).Row
Next
End Sub
 
Last edited:
Basically I was info from each cell in a column be placed in one specific cell in seperate worksheets. So if I have info in column A (let's say 1, 2, 3) and several worksheets (C,D,F). I want info from Column A into each worksheet at cell C4. So cell C4 in workshet C should have 1, C4 in D has 2, F has 3, and so on.
 
So warming a couple of neurons, just respecting Logic ! …​
Code:
Sub Demo()
         Dim L&, V
             L = 1
    For Each V In Sheet1.Cells(1).CurrentRegion.Columns(1).Value
          If L = Worksheets.Count Then Exit For
             L = L + 1
        Worksheets(L).[C4].Value = V
    Next
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Back
Top