How to transfer specific range to another sheet?

mtbthepro

Board Regular
Joined
Feb 22, 2017
Messages
91
This is below isn't working. I tried to find Account total and then copy everything from that row in between column "D:H" then transfer it to range c27 in sheet "AR SUMMARY". It doesn't seem to do anything. Is there a solution for this?
Code:
Sub transfering_Rental()Sheets("Space Rental").Activate
Set Sht = ActiveWorkbook.ActiveSheet
nlast = Cells(Rows.Count, "A").End(xlUp).Row
                    
                    For n = nlast To 1 Step -1
                   If Sht.Cells(n, 2).Value = "ACCOUNT TOTAL" Then
            
                            Sht.Rows(n).Range("D:H" & n).Copy
                            Sheets("AR SUMMARY").Range("C27" & n).PasteSpecial xlPasteValues
                        End If
          Next n
         
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
this is your code my friend

Code:
Option Explicit
Option Compare Text


Sub transfering_Rental()
Dim nlast As Long
Dim sht As Worksheet
Dim n As Integer

Sheets("Space Rental").Activate
Set sht = ActiveWorkbook.ActiveSheet
nlast = Cells(Rows.Count, "A").End(xlUp).Row
                    
For n = nlast To 1 Step -1
  If sht.Cells(n, 2).Value = "ACCOUNT TOTAL" Then           
   Range(Cells(n, "D"), Cells(n, "H")).Copy
   Sheets("AR SUMMARY").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  End If
Next n
End Sub
 
Last edited:
Upvote 0
where is the value "Account total"? in which column? If I suppose, that this value si in B columns, which was your macro looking for, then it should work ok...just tried it again and all good :)
 
Upvote 0
where is the value "Account total"? in which column? If I suppose, that this value si in B columns, which was your macro looking for, then it should work ok...just tried it again and all good :)
Yes it is in Column B but where is it pasteing in "AR SUMMARY"? Tried it again didn't work lol
 
Last edited:
Upvote 0
try this, I dont know, how consistent are your data in column A...if there can be possibility, that column A will have less values than column B, it might be cause of not working this code..try this

Code:
Option Explicit
Option Compare Text


Sub transfering_Rental()
Dim nlast As Long
Dim sht As Worksheet
Dim n As Integer

Sheets("Space Rental").Activate
Set sht = ActiveWorkbook.ActiveSheet
nlast = Cells(Rows.Count, "B").End(xlUp).Row
                    
For n = nlast To 1 Step -1
  If sht.Cells(n, 2).Value = "ACCOUNT TOTAL" Then
   Range(Cells(n, "D"), Cells(n, "H")).Copy
   Sheets("AR SUMMARY").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  End If
Next n
End Sub
 
Last edited:
Upvote 0
Okay it works now but its pasting in the wrong area. How do I pick a range? Range for this is C27 in AR SUMMARY
 
Upvote 0

Forum statistics

Threads
1,214,631
Messages
6,120,640
Members
448,974
Latest member
DumbFinanceBro

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