VBA code to use a for loop across all sheets in a workbook to select the variable contents?

 

I have a workbook with multiple sheets, in each sheet I need to copy the same row contents to my master list. I have a code to get one cell value (which is N7) in each sheet to my master,

The problem is, in some sheets, the cell value to be get into master will be one cell , In other sheets, it will be two or more cells like (N7 TO N11)

How should I get this in to my master? My current code is,

Dim DataFile As String
Workbooks.Open Filename:=Range("T3").Value
DataFile = ActiveWorkbook.Name
ThisWorkbook.Activate
Range("C4").Select
For i = 1 To Workbooks(DataFile).Worksheets.Count
ActiveCell.Value = Workbooks(DataFile).Worksheets(i).Range("N7").Value
ActiveCell.Offset(1, 0).Select
Next i

Please help me on this.

By: Divya S

4 thoughts on “VBA code to use a for loop across all sheets in a workbook to select the variable contents?

  1. ig

    Thanks for the good writeup. It in truth used to be a amusement account it.
    Look complicated to more delivered agreeable from you!
    However, how could we be in contact?

  2. Austin Delavergne

    It is in point of fact a nice and helpful piece of info. I am glad that you simply shared this helpful info with us. Please stay us up to date like this. Thank you for sharing.

  3. Herbertsuime

    I treasure the knowledge on your site. Thanks! [url=http://baraita.net/weight-reduction-with-suppport-or-without-it/]http://baraita.net/weight-reduction-with-suppport-or-without-it/[/url]

Comments are closed.