Change Range from one column to one Cell

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Good evening, the follow macro works great if I need to find all fillable text starting in Column K2. I would like it to look into one specific cell "K6" and it would put the result in "H8".
I thought I could change the data range to :
Excel Formula:
Data = Range("K6").Value
of course it didn't help. Again everything works find I just it to read one specific cell "K6".

Thank you very much indeed.


VBA Code:
Sub International_Msn()
  Dim r As Long, Data As Variant, Result As Variant
  Data = Range("K2", 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 "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then
      Result(r, 1) = Result(r, 1) & Mid("/International", 1 - (Result(r, 1) = ""))
    End If
  Next
  Range("H8").Resize(UBound(Result)) = Result
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Is this what you mean ???
VBA Code:
Sub International_Msn()
    If Cells(6, 11) Like "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then Cells(8, 8) = Cells(6, 11)
End Sub
 
Upvote 0
Is this what you mean ???
VBA Code:
Sub International_Msn()
    If Cells(6, 11) Like "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then Cells(8, 8) = Cells(6, 11)
End Sub
I see the (K6) with Cells(6,11), but the code that you have looks over- simplified. All the other information like the result line is missing. The macro I included is perfect, I just want to change it from looking at all the lines in (K2) to one specific cell (K6), and if it meets the criteria "Like" then it will insert the result "International" into Cell "H8".

Thank you,
 
Upvote 0
MAybe this then
VBA Code:
Sub International_Msn()
     If Cells(6, 11) Like "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then
      Cells(8, 8) = Cells(6, 11) & Mid("/International", 1 - (Cells(6, 11) = ""))
    End If
End Sub
 
Upvote 0
MAybe this then
VBA Code:
Sub International_Msn()
     If Cells(6, 11) Like "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then
      Cells(8, 8) = Cells(6, 11) & Mid("/International", 1 - (Cells(6, 11) = ""))
    End If
End Sub
I'll have to try that. It is much shorter than mine.
 
Upvote 0
MAybe this then
VBA Code:
Sub International_Msn()
     If Cells(6, 11) Like "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then
      Cells(8, 8) = Cells(6, 11) & Mid("/International", 1 - (Cells(6, 11) = ""))
    End If
End Sub
That is much closer, the only thing is it inputs the text in (6,11) at the beginning of Cell (8,8). What suppose to happen is if cell (8,8) is blank then in will insert "international" which "Mid("/International" provides. If there is already text in Cell (8,8) then "/international" is inserted.

Thank you,
 
Upvote 0
MAybe this then
VBA Code:
Sub International_Msn()
     If Cells(6, 11) Like "[ACEFGHIKLMNPQRSW0124678][ESU][N]*" Then
      Cells(8, 8) = Cells(6, 11) & Mid("/International", 1 - (Cells(6, 11) = ""))
    End If
End Sub
I have about 15 of these codes, and some may end a result where more than just one macro "may" apply. This is why I had it so one text doesn't get overwritten. The macro is going to run through all of these.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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