Загрузка страницы

Do Loop through a table with an If Statement in Excel VBA -Code Included

Grab the Free VBA Quick Reference Guide
https://chrisjterrell.com/p/getting-started
A subscriber to the youtube channel requested this video. The subscriber wanted to use a Do Loop to go through a table of data and if column 1 was the same as the row above column 2 would not change. If it was the same it would do nothing but if it was different then combine column 1 and 2 in column 2.

Code:
==========
Sub DowithIf()

rw = 11
cl = 2
erw = 1000

Do While rw _ erw
Cells(rw, cl + 1).HorizontalAlignment = xlCenter

If Cells(rw, cl) __ Cells(rw - 1, cl) Then
Cells(rw, cl + 1) = Cells(rw, cl) & " - " & Cells(rw, cl + 1)
Cells(rw, cl + 1).Interior.Color = 13431551
ElseIf Cells(rw, cl) = "" Then
Exit Do
End If


rw = rw + 1
Loop

Columns(2).Clear

Columns(3).AutoFit

End Sub

Видео Do Loop through a table with an If Statement in Excel VBA -Code Included канала EverydayVBA
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
27 июня 2016 г. 8:41:04
00:15:04
Яндекс.Метрика