Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:57:34+00:00 2026-06-18T08:57:34+00:00

New to VBA, so be gentle. I have a 7 columns, A:H. The first

  • 0

New to VBA, so be gentle.

I have a 7 columns, A:H. The first column is a unique numerical identifier (starts at 0 and should increase each time I paste a new selection via this macro). The second column is Date which is entered in by hand after being prompted.

I want to be able to highlight a range of cells, activate the macro, and the macro move the data highlighted and paste it in next available chunk of space between the C and I columns. At the beginning, the macro prompts a dialog box asks the user for the date. I want this date to be entered at each point along Column B (in the next empty cell) for each cell in the selection.

Here are how the columns are formatted now: https://i.stack.imgur.com/jtVBg.png

Then, for each cell in the selection, I want it to be associated with a numerical ID. So the script would look to see what the last number was in column A, add one to that, and paste that for each cell in the current selection.

Here’s my code, but as I’m new to this, it’s completely broken.

For the DialogBox:

Sub SuperMacro()

    Dim c As Object
    Dim dateManager As String
    dateManager = InputBox(Prompt:="Enter the Date for Selection", _
          Title:="Date Manager", Default:="1/24/2013")

    If strName = "Your Name here" Or _
        strName = vbNullString Then
        Exit Sub
    End If

    For Each c In Selection
        Range("A1").End(xlDown).Offset(1, 0).Select  'Paste the date for each cell in selection
        ActiveSheet.Paste
    Next c

     'Attempt to move all date from selected area to next available chunk of space between C1 and H1.  
     Selection.Copy
     Range("C1:H1").End(xlDown).Offset(1, 0).Select
     ActiveSheet.Paste

End Sub

EDIT: Figured out a solution for the ID enumeration issue and column movement:

Sub CopyTest()

    Dim a As Range, b As Range
    Dim value As Integer

    Selection.Copy
    Set a = Selection
    Range("B1:H1").End(xlDown).Offset(1, 0).Select
    ActiveSheet.Paste

    value = (Range("A1").End(xlDown)) + 1
    For Each b In a.Rows
        Range("A1").End(xlDown).Offset(1, 0).Select
        ActiveCell.value = value
    Next

End Sub

Let me know if there is a more efficient way of doing this.

FOund a solution myself, for others:

Sub SuperMacro()

Dim a As Range, b As Range
Dim currentID As Integer


Set a = Selection
Selection.Cut Range("C1:I1").End(xlDown).Offset(1, 0) 'Pastes to appropriate column


currentID = Range("A1").End(xlDown).Value


For Each b In a.Rows
    Range("A1").End(xlDown).Offset(1, 0) = currentID + 1
    Range("B1").End(xlDown).Offset(1, 0) = InputBox("Enter Date", "Date Helper")
Next b

End Sub

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:57:35+00:00Added an answer on June 18, 2026 at 8:57 am

    Here’s the answer I found:

    Dim a As Range, b As Range
    Dim currentID As Integer
    
    
    Set a = Selection
    Selection.Cut Range("C1:I1").End(xlDown).Offset(1, 0) 'Pastes to appropriate column
    
    
    currentID = Range("A1").End(xlDown).Value
    
    
    For Each b In a.Rows
        Range("A1").End(xlDown).Offset(1, 0) = currentID + 1
        Range("B1").End(xlDown).Offset(1, 0) = InputBox("Enter Date", "Date Helper")
    Next b
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to vba and I have problem understanding the workbooks in vba
I am new to VBA but have previous experience with PHP programming logic and
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I am new to VBA and trying to write a simple macro. I have
I am new to VBA. I have written this code inside a button click
I am fairly new to Excel VBA and have been trying to look for
First let me premise with I am very new to access vba. My question
I'm new to VBA and Access. I have to create an inventory loan form
I'm new with VBA and I'm stuck somewhere. I have to copy last row
I am really new to VBA coding. Problem I have is this: B60, D60,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.