Excel VBA move and remove a value from a range

pretzman21

New Member
Joined
Aug 7, 2018
Messages
11
I would like to use an excel VBA to in this case remove an "a" from a group of cells, and move one of them to a new cell. In the formula below, it has added the "a" to K48 and removed the a's from L48:N48. I would like to to search a range, for me it is L2:N100. The "a" needs to be removed from any grouping and placed in that corresponding K cell. It needs to be able to do this any amount of times. Can this formula be adjusted to do this, or a new formula perhaps? Any help is appreciated. Thank you.

Sub MoveAValue()

Range("L48:N48").Select
Selection.Replace What:="a", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Range("K48").Select
ActiveCell.FormulaR1C1 = "a"
Range("K49").Select
End Sub
 

Attachments

  • Move and remove A.JPG
    Move and remove A.JPG
    45.2 KB · Views: 5

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I was able to update my formula to what you see below, however, this only removes the "a" if it exists, which is about 50% of what I need. I still would like to have the value in Row K to update to have an "a" if it detects an "a" in the equivalent L row.


AbsentValue = "a"
For X = 1 To Range("L" & Rows.Count).End(xlUp).Row
With Range("L" & X)
If Left(.Value, 1) = AbsentValue Then .Value = Replace(.Value, EqualsSign, "'=", , 1)
End With
Next

Columns("L:N").Select
Selection.Replace What:="a", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2

Range("A1").Select
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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