Copy to by cell contents

plwandatw

New Member
Joined
Apr 17, 2023
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I use the following to copy data on change to another worksheet, on the current worksheet D is a category that I need to copy cell E to sheet1 where the categorys broken down into columns D:L

Thank you

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D:D")) Is Nothing Then
Cat
End If
End Sub

Sub Cat()
Dim irow As Long

irow = ActiveCell.Row

Range(Cells(irow, "A"), Cells(irow, "E")).Copy

Sheets("Sheet1").Select
Range("A" & Rows.Count).End(xlUp).EntireRow.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
True, Transpose:=False

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I think you are going to need to show us some images of your data source and where you are poasting it, as all this is highly dependent upon your sheet structure. So we need to see what it all looks like.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
ActiveWorkSheet
Check #DateToExpenses CategoryWithdrawalDepositClearedBalance
$106,901.94
270615-Jul-23KTQMAdvertising$237.44$106,664.50


Sheet1
Check#DatePayeeRodeoAdvertisingCTREventsLaborDonationsOP Expenses
270615-Jul-23KTQM$ 237.44
 
Upvote 0
Are "Rodeo", "Advertising", "CTR", "Events", "Labor", "Donations", and "OP Expenses" the only possibilities for the Expenses Category?
Will those expenses ALWAYS be listed in that exact order in Sheet1, going across the columns?
Are we only concerned with Withdrawal amounts and not Deposit amounts?

I also see that you have this code being triggered when a value is entered in column D (Expenses Category).
Will this ALWAYS be the last column of data entered?
If that value is entered before an amount is entered in the Withdrawal field, it would be sent over to Sheet1 before there is an amount.
 
Upvote 0
Are "Rodeo", "Advertising", "CTR", "Events", "Labor", "Donations", and "OP Expenses" the only possibilities for the Expenses Category?
Will those expenses ALWAYS be listed in that exact order in Sheet1, going across the columns?
Are we only concerned with Withdrawal amounts and not Deposit amounts?

I also see that you have this code being triggered when a value is entered in column D (Expenses Category).
Will this ALWAYS be the last column of data entered?
If that value is entered before an amount is entered in the Withdrawal field, it would be sent over to Sheet1 before there is an amount.
Joe4,

Yes, these are the only categories that we are required to provide. Yes, Expenses Category will be the last input (I'm going move this column to E for better flow). Sheet1 categories will not change columns.

Thank you
 
Upvote 0
I updated the following code that might be a bit cumbersome but it works. The issue now is it only works with worksheet "Jul" is there a way to use the same code for all 12 worksheets (Jan-Dec)?

VBA Code:
Sub Cat()
Dim irow As Long

irow = ActiveCell.Row

Application.ScreenUpdating = False
Range(Cells(irow, "A"), Cells(irow, "C")).Copy
Sheets("Sheet1").Select
Range("A" & Rows.Count).End(xlUp).EntireRow.Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    True, Transpose:=False
    
    Sheets("jul").Select
    
If Cells(irow, "e").Value = "Rodeo" Then
        Cells(irow, "d").Copy
    Sheets("Sheet1").Select
    ActiveCell.Offset(0, 3).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    True, Transpose:=False
      
    ElseIf Cells(irow, "e").Value = "Advertising" Then
        Cells(irow, "d").Copy
        Sheets("Sheet1").Select
        ActiveCell.Offset(0, 4).Select.Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        True, Transpose:=False

    ElseIf Cells(irow, "e").Value = "CTR" Then
        Cells(irow, "d").Copy
        Sheets("Sheet1").Select
        ActiveCell.Offset(0, 5).Select.Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        True, Transpose:=False
 
    ElseIf Cells(irow, "e").Value = "Events" Then
        Cells(irow, "d").Copy
        Sheets("Sheet1").Select
        ActiveCell.Offset(0, 6).Select.Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        True, Transpose:=False

    ElseIf Cells(irow, "e").Value = "Labor" Then
        Cells(irow, "d").Copy
        Sheets("Sheet1").Select
        ActiveCell.Offset(0, 7).Select.Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        True, Transpose:=False
     
    ElseIf Cells(irow, "e").Value = "Donations" Then
        Cells(irow, "d").Copy
        Sheets("Sheet1").Select
        ActiveCell.Offset(0, 8).Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        True, Transpose:=False
    
    ElseIf Cells(irow, "e").Value = "OP Expenses" Then
        Cells(irow, "d").Copy
        Sheets("Sheet1").Select
        ActiveCell.Offset(0, 9).Select.Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        True, Transpose:=False
    
    
End If
Sheets("jul").Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,266
Members
449,093
Latest member
Vincent Khandagale

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