Creating VBA to copy data to mouse cursor location.

SuperRandomGuy

New Member
Joined
Jan 13, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello Everyone,
First off thank you in advance. I am still teaching myself VBA in Excel so please bear with me.

I have a question. I have data that I would like to be copied and pasted to another sheet, where the mouse cursor is located at. Image1 is the data where I use a macro to format the data dump. Image2 is where I would like to paste the data. I was wondering if there was a way to paste the data, beginning to where the mouse cursor is at (on the second worksheet)? Image1, first table 123 MSF will copy H3:S3, go to the other worksheet and paste it where the mouse cursor is at. In this case I will move the mouse cursor to the next blank row. I would prefer to copy and paste at the mouse cursor because I don't want it to go to the next blank spot. There may be times where I will have to manually enter in information, etc. so it will be more useful if I initially move the cursor to the pasting location if I indeed need to paste from Image1.

Once a solution has been presented, I will create a macro that will paste to the mouse cursor (image2), move cursor 3 columns right and paste the next tables info (H7:S7), repeat. Currently, the first macro will take my data dump and format it so I can paste the info. I will need to do this for each shift (1-2-3). Right now I am copying and pasting each row. Not an awful task but one that can be automated. Each shift has 8 copy and paste procedures; 24 total copied data points for all the shifts. It would be of great help if I could do this with 3 macros (1 for each shift) or 1 (if there is a way to paste at the cursor). As long as the cursor is placed at the correct shift, it should paste the data, move to next table, paste, repeat. If I need to paste 2nd shift, I would just move the cursor to the 2nd shift table and paste the data.

If there is a different way to attack this, I am open to suggestions.
Thank you for your help!
 

Attachments

  • tbl1.png
    tbl1.png
    46.9 KB · Views: 24
  • tbl2.png
    tbl2.png
    63.6 KB · Views: 26

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I wouldn't even attempt this, mainly because I think a range input box would be so much simpler. AFAIK, mouse coordinates are relative to the screen, not the application window and not a sheet. Plus I believe that in Excel you need an API to even get that much.
Consider, using type 8
 
Upvote 0
Solution
Thank you for the input. I always thought that it could work like a macro but if it is screen pixels (as I am now reading about), I can see the problem. Thank you. I will check out other solutions.
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,337
Members
453,032
Latest member
Pauh

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