Loop through cells and add to range

leosmessi786

New Member
Joined
Oct 18, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
So Basically I'm going through column C. For all cells that satisfy that if statement I want to add them to the Port Range. Then at the end of the code I want to paste all those cells together into another cell. Can't wrap my head around on how to add the cells to the range however. IF someone could please help me that would be awesome!!!!

Dim x As Integer
Dim nFirstSectionStartRow As Integer
Dim nFirstSectionRows As Integer
Dim Port As Range


x = 0

nFirstSectionRows = Range("C10", Range("C10").End(xlDown)).Rows.Count

nFirstSectionStartRow = 9

For x = nFirstSectionStartRow + 1 To nFirstSectionStartRow + nFirstSectionRows

If Cells(x, 3).Value + 10 < Cells(x + 1, 3).Value Then

?????Confused as to what I do here


End If



x = x + 1

Next x
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,395
Messages
6,119,265
Members
448,881
Latest member
Faxgirl

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