VBA Nested loops in tabular data

I've had a pretty thorough search but I'm still struggling with this problem. Essentially, I have a list of various titles, each of which has 10 variables corresponding, which may or may not have data points.

VBA Nested loops in tabular data

I'd like to loop through the first column, with a nested loop going through each row to count and record the number of populated data points in each. Mostly I'm not sure how to reference cells in the second loop. Any help would be greatly appreciated!

Replay

I dont really understand your ultimate goal however i hope the code below will help you to go to the right direction.

As far as i understand i wrote a code that COUNT how many cells for each row where there s data.

I am not really sure if it is what you want but let me know and i will edit my code to your requirement.

Option Explicit

Sub test()

Dim wb As Workbook
Dim ws As Worksheet
Dim Lastrow As Long
Dim i As Long, j As Long, c As Long

Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1") '  Change the name of your worksheet

Lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row ' Find the las row

With ws

        For i = 1 To Lastrow 'Start at row 1 until the last row

            c = 0

                For j = 2 To 11 ' 10 Variables (until the column "L")
                        If Not IsEmpty(.Cells(i, j)) Then c = c + 1  ' Count and record the number of populated data points in each columns
                Next j

            .Cells(i, 12).Value = c 'Past the result in column "L"

        Next i

    End With

End Sub

Category: excel vba Time: 2016-01-26 Views: 1
Tags: excel vba

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.213 (s). 12 q(s)