Autofill in a variable range
Closed
                                    
                        Vemoridi                    
                                    -
                            Dec  8, 2011 at 05:54 PM
                        
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 8, 2011 at 08:47 PM
        venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Dec 8, 2011 at 08:47 PM
        Related:         
- Autofill in a variable range
 - Safari autofill - Guide
 - Clear autofill chrome - Guide
 - How to increase wifi range from router settings - Guide
 - Autofill opera - Guide
 - Apple airtags range - Guide
 
1 response
                
        
                    venkat1926
    
        
                    Posts
            
                
            1863
                
                            Registration date
            Sunday June 14, 2009
                            Status
            Contributor
                            Last seen
            August  7, 2021
            
            
                    811
    
    
                    
Dec 8, 2011 at 08:47 PM
    Dec 8, 2011 at 08:47 PM
                        
                    when you are learning macro from recording macro you must introuduce number of message boxes (msgsbox) so that you know what you are doing and correct it if wrong 
one more thing there is a line
what is stsrRow . there is no mention. Is it a typo
correct it if necessary
now dubug the macro below. how
reduce the size of spreadsheet and vbeditor (macro area) by clicking the center icon on the top right left to x icon and keep the two side by side
now go to macro and keep the cursor within some where in the macro and successively hit F8.
you will find some descrepancy and correct it.
            one more thing there is a line
Rows(strRow).Select
what is stsrRow . there is no mention. Is it a typo
correct it if necessary
now dubug the macro below. how
reduce the size of spreadsheet and vbeditor (macro area) by clicking the center icon on the top right left to x icon and keep the two side by side
now go to macro and keep the cursor within some where in the macro and successively hit F8.
you will find some descrepancy and correct it.
Sub test()
Dim NRow As Integer 'Row number
Dim strRow1 As String 'Limit 1 of my range
Dim strRow2 As String 'Limit 2 of my range
'I want to add the row according to the selected cell
      ActiveCell.EntireRow.Select
MsgBox ActiveCell.Row
'To get the row of my selection
      NRow = Selection.Row
MsgBox NRow
'Add line
      Selection.EntireRow.Insert Shift:=xlDown
'Define the range of my rows
        strRow1 = NRow & ":" & NRow
        strRow2 = NRow - 1 & ":" & NRow
       MsgBox strRow1
       MsgBox strRow2
       
        Rows(strRow).Select
        MsgBox Selection.Address
        Selection.AutoFill Destination:=Rows(strRow2), Type:=xlFillDefault
End Sub