Only three minor Changes in VBA Code

Vishaal

Well-known Member
Joined
Mar 16, 2019
Messages
533
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
  2. Web
want to make some changes in below code, need only 3 changes, help pls

we have added the number in code where we need to change.................

1. Selection.AutoFill Destination:= it will select range E and last range of E will be till last filled data in D
2. range("E14:E1779").Select = it will be From E14 to last filled data in D
3. Selection.AutoFill Destination:=Range("HH14:HH1779") - it will select from HH14 and last range will be till last filled data in D

Rich (BB code):
Sub Macro2468()
'
    Range("E14").Select
    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(MATCH(RC4,R1C:R4C,0)),"""",""Na"")"
    Range("E14").Select
1.    Selection.AutoFill Destination:=Range("E14:E1779")
2.    Range("E14:E1779").Select
    Selection.Copy
    Range("F14:HF14").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
        Range("HH14").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(AND(RC[-211]=""Na"",R[1]C[-211]=""""),COUNTIF(R1C[-211]:RC[-211],""Na"")-SUM(R12C:R[-1]C),"""")"
    Range("HH14").Select
3.    Selection.AutoFill Destination:=Range("HH14:HH1779"), Type:=xlFillDefault
 
     
    Application.ScreenUpdating = True
    With ActiveSheet
        lr = .Cells(Rows.Count, "HH").End(xlUp).Row
        Set Rng = Range("HH14:HH" & lr)
        Rng.Copy
        For i = 217 To 425
            .Cells(14, i).PasteSpecial Paste:=xlPasteFormulas
            With .Cells(14, i).Resize(lr + 1)
                End With
        Next
    End With
    Application.ScreenUpdating = True
 
 
        Cells.Select
    Application.CutCopyMode = False
    With Selection
        .HorizontalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With

    Range("E14").Select

End Sub
 
Last edited by a moderator:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Someone please correct me if I'm wrong but wouldn't something like this work?

VBA Code:
dim last as long
long = Cells(Rows.Count. "D").End(xlUp).Row
' update ranges to a definition similar to ("E14" & last)
 
Upvote 0
How about
VBA Code:
   Dim UsdRws As Long
   UsdRws = Range("D" & Rows.Count).End(xlUp).Row
   Range("E14:E" & UsdRws).FormulaR1C1 = "=IF(ISNUMBER(MATCH(RC4,R1C:R4C,0)),"""",""Na"")"


   Range("HH14:HH" & UsdRws).FormulaR1C1 = _
        "=IF(AND(RC[-211]=""Na"",R[1]C[-211]=""""),COUNTIF(R1C[-211]:RC[-211],""Na"")-SUM(R12C:R[-1]C),"""")"
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,986
Members
449,058
Latest member
oculus

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