Any of those help I have imported a csv file to sheet(4). I would like to select all rows and copy them to sheet(3). I would like to place the rows from sheet(3) on sheet(4) after any used rows. When I try and get the total number of rows used on sheet(3) "TotalRows" I get the number of rows imported on sheet(4). The reason is that if i have a fifth sheet(5). I would to place them at the end of rows on sheet(3). , Why don't you try it simpler and more explicit. HTH.
Dim ws As Worksheet, tws As Worksheet
Set tws = CurrentWorkbook.Sheets("Sheet3")
For Each ws In CurrentWorkbook
If ws.Name <> "Sheet3" Then
ws.UsedRange.Copy tws.Range("A" & tws.Rows.Count).End(xlUp).Offset(1, 0)
it helps some times You could use the activesheet's index: After:=Sheets(Activesheet.Index). Not sure if you know much VBA, but as the name implies, whatever your currently active sheet is, that index will be used. Without knowing more of your code, it will work for the specific instance you asked about here. BUT if you have multiple worksheets (which you do), you'll probably instead want to set a variable for the worksheet you're working in, then use that in the Sheets() part...i.e.
Dim x As Integer
Dim myWorksheet As Worksheet
myWorksheet = Sheets("Data Sheet")
x = InputBox("Enter number of times to copy sheet, puts copies at end of sheet list")
For numtimes = 1 To x
'Loop by using x as the index number to make x number copies.
Execute Excel Macro to Copy All Sheets to Master Sheet When Any Cell in Active Sheet Column Changes
may help you . To answer the actual question - the reason your code is going in to an infinite loop is due to two reasons: You have not disabled events within the event, so by pasting over the range F2:F251 you are firing the event again and again and again. You are getting the last row of MasterRecord, but you are not using the Range on MasterRecord, rather, the sheet the event was fired from.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
' Target is already a range, no need to get the address explicitly
If (Intersect(Target, Sh.Range("F1:F251")) Is Nothing) Then Exit Sub
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim master As Worksheet: Set master = ThisWorkbook.Worksheets("MasterRecord")
Dim ws As Worksheet
Dim sheets As Variant: sheets = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
Dim sheet As Variant
For Each sheet In sheets
Set ws = ThisWorkbook.Worksheets(sheet)
master.Range("A" & master.Range("A" & master.Rows.Count).End(xlUp).Row + 1).PasteSpecial xlPasteValues
Set master = Nothing
Set ws = Nothing
Application.EnableEvents = True
Application.ScreenUpdating = True
Covert Excel VBA Macro from Active Sheet to all sheets without focus