VBA Code / Formula - Modify

Vishaal

Well-known Member
Joined
Mar 16, 2019
Messages
543
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
  2. Web
Hi,

Thanks in Advance,

Its possible in VBA or code or formula to automate from column IX to column SO (ROW1798), its copy the formula and paste in only 5 or 10 column and after that copy that cells and paste special as value and make this till SO (ROW1798)


1. It will copy the formula

"=IF(AND(RC[-253]=""Na"",R[1]C[-253]=""Yes""),COUNTIF(R2C[-253]:RC[-253],""Na"")-SUM(R1C:R[-1]C),"""")"

2. Paste on range IX10:IX1798

3. Now for the range IY10 to SO10 automatically paste the formula as per following details
(i) paste in next five coloumn from "IY to JC"
(ii) copy that five coloumn (IY to JC) and paste as values

After that it will do for next five coloumns till SO10


Because its time taken for counting the "ix to so"


Currently i am using the following code



Range("IX10").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-253]=""Na"",R[1]C[-253]=""Yes""),COUNTIF(R2C[-253]:RC[-253],""Na"")-SUM(R1C:R[-1]C),"""")"
Range("IX10").Select
Selection.Copy
Range("IX11:IX1798").Select
ActiveSheet.Paste
Application.CutCopyMode = False


Sub test6()
Application.ScreenUpdating = False
Range("IX10:IX1798").Copy
Range("IY10:JW10").PasteSpecial xlPasteAll
Range("IY10:JW10").PasteSpecial xlPasteValues

Range("JX10:KV10").PasteSpecial xlPasteAll
Range("JX10:KV10").PasteSpecial xlPasteValues




Range("KW10:LU10").PasteSpecial xlPasteAll
Range("KW10:LU10").PasteSpecial xlPasteValues




Range("LV10:MT10").PasteSpecial xlPasteAll
Range("LV10:MT10").PasteSpecial xlPasteValues

Range("MU10:NS10").PasteSpecial xlPasteAll
Range("MU10:NS10").PasteSpecial xlPasteValues

Range("NT10:OR10").PasteSpecial xlPasteAll
Range("NT10:OR10").PasteSpecial xlPasteValues

Range("OS10:PQ10").PasteSpecial xlPasteAll
Range("OS10:PQ10").PasteSpecial xlPasteValues

Range("PR10:QP10").PasteSpecial xlPasteAll
Range("PR10:QP10").PasteSpecial xlPasteValues

Range("QQ10:RO10").PasteSpecial xlPasteAll
Range("QQ10:RO10").PasteSpecial xlPasteValues

Range("RP10:SO10").PasteSpecial xlPasteAll
Range("RP10:SO10").PasteSpecial xlPasteValues




Application.ScreenUpdating = True
Application.CutCopyMode = False

MsgBox "Done"
End Sub
 
Last edited:

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.
I just want to copy the formula

Rich (BB code):
Range("IX10").Select
Rich (BB code):
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-253]=""Na"",R[1]C[-253]=""Yes""),COUNTIF(R2C[-253]:RC[-253],""Na"")-SUM(R1C:R[-1]C),"""")"
Range("IX10").Select
Selection.Copy
Range("IX11:IX1798").Select
ActiveSheet.Paste
Application.CutCopyMode = False
and it will work on the coloumn till SO (ROW1798),
1. Paste next five column
2. copy what we have past and paste special values
and do this till column SO (Row 1798)


like this but it have done manually
Rich (BB code):
Rich (BB code):
Sub test6()
Application.ScreenUpdating = False
Range("IX10:IX1798").Copy
Range("IY10:JW10").PasteSpecial xlPasteAll
Range("IY10:JW10").PasteSpecial xlPasteValues

Range("JX10:KV10").PasteSpecial xlPasteAll
Range("JX10:KV10").PasteSpecial xlPasteValues

Range("KW10:LU10").PasteSpecial xlPasteAll
Range("KW10:LU10").PasteSpecial xlPasteValues

Range("LV10:MT10").PasteSpecial xlPasteAll
Range("LV10:MT10").PasteSpecial xlPasteValues

Range("MU10:NS10").PasteSpecial xlPasteAll
Range("MU10:NS10").PasteSpecial xlPasteValues

Range("NT10:OR10").PasteSpecial xlPasteAll
Range("NT10:OR10").PasteSpecial xlPasteValues

Range("OS10:PQ10").PasteSpecial xlPasteAll
Range("OS10:PQ10").PasteSpecial xlPasteValues

Range("PR10:QP10").PasteSpecial xlPasteAll
Range("PR10:QP10").PasteSpecial xlPasteValues

Range("QQ10:RO10").PasteSpecial xlPasteAll
Range("QQ10:RO10").PasteSpecial xlPasteValues

Range("RP10:SO10").PasteSpecial xlPasteAll
Range("RP10:SO10").PasteSpecial xlPasteValues

Application.ScreenUpdating = True
Application.CutCopyMode = False

MsgBox "Done"
End Sub
 
Upvote 0
can we use something like this

as the following formula

Sub Delete_If()
'Modified 8/26/2019 3:47:12 AM EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = Lastrow To 1 Step -1
If Cells(i, 1).Value = Cells(i, 2).Value Then Rows(i).Delete
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Similar threads

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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