VBA to copy data from one cell, based on data in another cell (formula output), and paste at the end of a table in another sheet

keikii

New Member
Joined
Jul 19, 2019
Messages
1
I've been trying to figure this out for at least ten hours total now, and I have to admit I cannot do it myself. I'm just too new at VBA and too bad at programming.

Ultimate End Goal: to create a table of Authors based on data entered in a primary table, upon entry or update, without duplicates and ignoring blanks

Current goal: to copy a cell with the Author Name from the primary table to the end of a table on another sheet on entry or update, without duplicates and ignoring blanks
current setup: column with Author Name, validation column with whether or not that Author Name is in the Author table​
current problem: - I really do not have a clue what I'm doing​
- I can get the cell to transfer over to the second sheet if I enter data in a new row with Author Name column first, and all other data after that, but I need to be able to have it update on change, too.​

previous setup: macro to copy cell of appropriate column in selected row to Author Table on double click
previous problem: ultimately needed more automation

working VBA Code:
Code:
Sub AuthorCopyIdent()'
' Macro to Copy Author to Author Table
'
Range("C" & (ActiveCell.Row)).Select
Selection.Copy
Sheets("Authors").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Books").Select
End Sub
Note: Worked well for the previous setup, but I cannot figure out how to alter for more automation
Secondary Note: this does not seem to work if there is one row in the table that is blank. Minor issue, but a bit irksome.

Code:
Private Sub Worksheet_Calculate()
     On Error GoTo myerror
    Application.EnableEvents = False
    If Me.Range("J1").Value <> Me.Range("K1").Value Then
        Me.Range("K1").Value = Me.Range("J1").Value
 
        Call Module3.AuthorCopyIdent
    End If




myerror:
    Application.EnableEvents = True
End Sub
Module 1:[INDENT]Public Function LastRow() As Long[/INDENT]
[INDENT]    Application.Volatile[/INDENT]
[INDENT]    ActiveSheet.AutoFilterMode = False[/INDENT]
[INDENT]    LastRow = ActiveSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row[/INDENT]
[INDENT]End Function[/INDENT]
Notes: Works great if I'm adding a new row, but because it calls the old setup macro, it works only on TAB not ENTER, and I would like it to work for both. Also does not work if I add data in in any other column but the author name column first.
Original Source Code: https://www.mrexcel.com/forum/excel...pon-new-row-insert-using-vba.html#post3909496


Also tried: a worksheet_change sub that I have since lost the code for because it doesn't work because my validation column is based on a formula

Anticipated problems: if I have to edit the author name for any reason, it would create an entirely new row in the Authors table, when I would want to update the old entry if possible, or delete if it was a misspelled dupe. I haven't even been able to begin working on this anticipated problem

Excel version: current Windows version.

I don't know what else to add to this, if you have any questions just ask.

Any help at all would be helpful, even if I'm just going about this all wrong. Thank you for looking at this because I'm seriously lost.


 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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