How to run Macro when press enter automatically and paste in different cell

0 votes

I made a macro that allows me to just copy and paste, however, I don't know...

  • How do I have a macro run automatically whenever I press "C13"?
  • Every time you copy from cell "C13" and paste it in the sheet "AWB Scan Record," make sure to do so vertically in a new cell to build a table. In the example below, this is done by pasting into cell "A3," then the following time, "A4", "A5", and so on.
Apr 10, 2023 in Others by narikkadan
• 63,600 points
735 views

1 answer to this question.

0 votes

A Worksheet Change: Keep Record of Each Scan

  • This code needs to be copied to the sheet module (e.g. Sheet1) of the worksheet with cell C13 (Not in Thisworkbook or a standard module e.g. Module1).
  • There is nothing to run, it runs automatically: on each manual change in cell C13, its value is copied to the first available cell, the cell below the bottom-most non-empty cell, in column A of the other specified worksheet.
Option Explicit
 
Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Cells.CountLarge > 1 Then Exit Sub
    Dim sCell As Range: Set sCell = Me.Range("C13")
    If Intersect(sCell, Target) Is Nothing Then Exit Sub
    
    Dim dws As Worksheet: Set dws = Me.Parent.Sheets("AWB Scan Record")
    If dws.FilterMode Then dws.ShowAllData
    
    Dim dCell As Range
    
    With dws.Range("A3")
        Set dCell = .Resize(dws.Rows.Count - .Row + 1) _
            .Find("*", , xlFormulas, , , xlPrevious)
        If dCell Is Nothing Then
            Set dCell = .Cells
        Else
            Set dCell = dCell.Offset(1)
        End If
    End With
    
    dCell.Value = sCell.Value
    
    MsgBox "Scan recorded.", vbInformation
    
End Sub
answered Apr 10, 2023 by Kithuzzz
• 38,000 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

How to format numbers as lakhs and crores in excel/ google spreadsheet when the number could be negative too?

Excel formatting, in my opinion, can only ...READ MORE

answered Oct 31, 2022 in Others by narikkadan
• 63,600 points
14,676 views
0 votes
1 answer

How do I run a VBA Sub routine continuously when working in a Workbook and not only when the Workbook is opened?

on Thisworkbook, put: Private Sub Workbook_Open() Call checkPW(True) End Sub Then ...READ MORE

answered Jan 14, 2023 in Others by narikkadan
• 63,600 points
594 views
0 votes
1 answer

Trying to run different macros based on value of cell in a range

This demonstrates one approach to loop through ...READ MORE

answered Jan 19, 2023 in Others by narikkadan
• 63,600 points
448 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,212 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,664 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
908 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,053 views
0 votes
1 answer

How to automatically assign a color to the maximum and minimum values in a set of selected cells in Excel?

See Conditional Formatting, which may be accessed ...READ MORE

answered Apr 7, 2023 in Others by Kithuzzz
• 38,000 points
544 views
0 votes
1 answer

What VBA code would I use to concatenate cell A2 & B2 in cell C2 and then have it Autofill down the column?

Solution Find the last row. Write a formula to ...READ MORE

answered Feb 14, 2023 in Others by Kithuzzz
• 38,000 points
1,016 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP