Advertisement
YasserKhalil2019

T4030_Transfer Specific Cells In Active Row

Oct 1st, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. https://excel-egy.com/forum/t4030
  2. ---------------------------------
  3.  
  4. Sub Transfer_Specific_Cells_In_Active_Row()
  5. Dim ws As Worksheet, sh As Worksheet, sRow As Long, lr As Long
  6.  
  7. Set ws = ThisWorkbook.Worksheets(1)
  8. Set sh = ThisWorkbook.Worksheets(2)
  9.  
  10. Application.ScreenUpdating = False
  11. If ws.Name <> ActiveSheet.Name Then MsgBox "First Sheet Must Be Activated", vbExclamation: Exit Sub
  12. sRow = ActiveCell.Row
  13.  
  14. If sRow > 1 And Range("A" & sRow) <> "" Then
  15. lr = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
  16.  
  17. sh.Range("A" & lr).Value = ws.Range("A" & sRow).Value
  18. sh.Range("B" & lr).Resize(, 3).Value = ws.Range("E" & sRow).Resize(, 3).Value
  19.  
  20. MsgBox "Data In Row " & sRow & " Was Transferred Successfully", vbInformation
  21. Else
  22. MsgBox "No Transfer Happened. Make Sure You Are Not In Row 1 And There Is Data In The Active Row", vbExclamation
  23. End If
  24. Application.ScreenUpdating = True
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement