decadence
Well-known Member
- Joined
- Oct 9, 2015
- Messages
- 525
- Office Version
- 365
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Hi, I am trying to get the data from one cell value and add it to another cell value but the result i keep getting is just one cell value being added to all the other cells values, can someone help please.
Code:
Dim Rng1 As Range, i As Range, Rng2 As Range, x As Range, a As Range, b As Range
Application.ScreenUpdating = False
For Each i In Range("A1:Z2")
Select Case i.value2
Case "IPN", "Part", "Part Number"
If Not Rng1 Is Nothing Then
Set Rng1 = Union(Rng1, i)
Else
Set Rng1 = i
End If
End Select
Next
If Rng1 Is Nothing Then Exit Sub
Application.ScreenUpdating = False
If Not Rng1 Is Nothing Then
Set Rng1 = Rng1.Resize(Cells(Rows.Count, Rng1.Column).End(xlUp).row).Offset(1).SpecialCells(xlCellTypeVisible)
End If
Application.ScreenUpdating = False
For Each x In Range("A1:Z2")
Select Case x.value2
Case "Foot", "Package", "Pack"
If Not Rng2 Is Nothing Then
Set Rng2 = Union(Rng, x)
Else
Set Rng2 = x
End If
End Select
Next
If Rng2 Is Nothing Then
MsgBox "Footprint not Found!"
Exit Sub
End If
Application.ScreenUpdating = False
If Not Rng2 Is Nothing Then
Set Rng2 = Rng2.Resize(Cells(Rows.Count, Rng2.Column).End(xlUp).row).Offset(1).SpecialCells(xlCellTypeVisible)
End If
Application.ScreenUpdating = False
For Each a In Rng1
For Each b In Rng2
If a.value2 = "DNF_" Then
a.Cells.value2 = a.Cells.value2 + b.Cells.value2
End If
Next
Next
End Sub