Reduce range from full Column to a single cell.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings I have a Macro and it works, but I think I can streamline it. The following is my Macro.

VBA Code:
Sub Domestic_Msn()
  Dim r As Long, Data As Variant, Result As Variant
  Data = Range("K8", Cells(Rows.Count, "K").End(xlUp)).Value
  Result = Range("H8").Resize(UBound(Data)).Value
  For r = 1 To UBound(Data)
    If Data(r, 1) Like "[ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][BJKLQV][ABCPEQJRUWYZ]*" Then
      Result(r, 1) = Result(r, 1) & Mid("/DOMESTIC MSN", 1 - (Result(r, 1) = ""))
    End If
  Next
  Range("H8").Resize(UBound(Result)) = Result
End Sub

The line I think I can reduce is
Excel Formula:
Data = Range("K8", Cells(Rows.Count, "K").End(xlUp)).Value

I only need Cell "K8".

Thank you,
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Since it is going to be fixed cell, then why not just use
Data = Range("K8").Value

Am I missing something here?
 
Upvote 0
Solution

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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