Hi,
I'm very new to VBA and am trying to automate several tasks that I complete for a very larger data set. After hours of scouring this wonderful site, I'm at an impasse and am asking for help. The below was found on this site and adapted to work for my needs, but I would like for the code to look at a dynamic range rather then a set number of columns or rows where the value can be.
My current table is A1:K1599, Cell I1599 = 0 therefore I want to delete the entire column. The below accomplishes that but my data set is never the same.
Sub Sample()
Dim ws As Worksheet
Dim i As Long
Dim delRange As Range
With Worksheets("Sources")
'~~> Loop through relevant columns
For i = 1 To 12
'~~> Check if the value is equal to 0
If UCase(Trim(.Cells(1599, i).Value)) = "0" Then
'~~> Store the Range to delete later
If delRange Is Nothing Then
Set delRange = .Columns(i)
Else
Set delRange = Union(delRange, .Columns(i))
End If
End If
Next i
End With
'~~> Delete the relevant columns in one go
If Not delRange Is Nothing Then delRange.Delete
End Sub
Display More
This section is where I believe the update is needed, but I don't know where to begin, What can I do to accomplish that? I would also like to accomplish this for rows as well. I will start another thread if needed.
'~~> Loop through relevant columns
For i = 1 To 12
'~~> Check if the value is equal to 0
If UCase(Trim(.Cells(1599, i).Value)) = "0" Then
Thanks in Advance,
Van