VB Help Needed: change X Col which contain "YES" to data at Col X + Merge VB Code

harky

Active Member
Joined
Apr 8, 2010
Messages
405
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
Hi,
I need a VB to change Col Q which contain "YES" to data at Col H (The rest col remain untouched)
and possible to merge with this VB Code?

Code:
Sub S2_AddZero()
    Dim a
    Dim i As Long
    Dim R As Range


    For Each R In Range("D2", Range("D" & Rows.Count).End(xlUp))
        If Len(R.Text) >= 5 And Left(R.Text, 1) <> "0" Then
            R.NumberFormat = "General"
        Else
            R.NumberFormat = "@"
            R.HorizontalAlignment = xlCenter
            R.Value = Right("00000" & R.Text, 5)
        End If
    Next R
End Sub



My data is like this
4bs8cS8.png


Result
qV6lNCk.png
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
How about
Code:
   With Range("Q:Q")
      .Replace "Yes", "=xxx", xlWhole, , False, , False, False
      .SpecialCells(xlFormulas, xlErrors).FormulaR1C1 = "=rc[-9]"
      .Value = .Value
   End With
This can simply be placed at the end of your existing macro
 
Upvote 0
thank you so much. it work great.

How about
Code:
   With Range("Q:Q")
      .Replace "Yes", "=xxx", xlWhole, , False, , False, False
      .SpecialCells(xlFormulas, xlErrors).FormulaR1C1 = "=rc[-9]"
      .Value = .Value
   End With
This can simply be placed at the end of your existing macro
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,787
Members
449,049
Latest member
greyangel23

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