Excel Newb needs help with VBA

lneuberger

New Member
Joined
Sep 28, 2023
Messages
9
Office Version
  1. 365
Platform
  1. MacOS
Hi everyone. I am trying to create a check in / check out system in excel for equipment. I created a pull down menu for IN and OUT. I am trying to figure out how to make it so that when IN is selected it will take the contents of one or two cells in that row and move it to another sheet. Basically trying to keep a history of who has checked something out.

I hope this is enough information. I attached a sample sheet in case you want to see. I appreciate any help.

test sheet.xlsx
ABCDEFGH
1ITEMSERIALMODELNOTESCHECK OUTCHECK OUT DATENAMEEMAIL
2
3DSLR'S
4DSLR 11520 3200 3461Canon T6ihas lens cap & Canon batteryINmikemike@kkkkkkkk.com
5DSLR 21520 3200 3464Canon T6ihas canon battery
6DSLR 31520 3200 3462Canon T6ihas lens cap & Canon battery
7DSLR 4missing #Canon SL2has lens cap & Canon battery
8DSLR 51120 7101 2723Canon SL2has lens cap & Canon battery
9DSLR 61120 7101 2721Canon SL2has lens cap & Canon battery
10DSLR 7# damagedCanon SL2has Canon battery -- paint peeling off flip-out screen
11DSLR 81120 7101 2724Canon SL2has Canon battery
12DSLR 91120 7101 2686Canon SL2has Canon battery
13DSLR 101120 7101 2679Canon SL2has Canon battery
14DSLR 111120 7101 2681Canon SL2has Canon battery
Sheet1
Cells with Data Validation
CellAllowCriteria
E4List=$K$2:$K$3
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Don't know if this will help you or not. Why don't you just have Check Out and Check In columns with dates? If there's no check in date, it's out.
ITEMSERIALMODELNOTESCHECK OUTCHECK INNAMEEMAIL
DSLR'S
DSLR 11520 3200 3461Canon T6ihas lens cap & Canon battery9/15/239/25/23mikemike@kkkkkkkk.com
DSLR 21520 3200 3464Canon T6ihas canon battery9/21/23
DSLR 31520 3200 3462Canon T6ihas lens cap & Canon battery
DSLR 4missing #Canon SL2has lens cap & Canon battery
DSLR 51120 7101 2723Canon SL2has lens cap & Canon battery
DSLR 61120 7101 2721Canon SL2has lens cap & Canon battery
DSLR 7# damagedCanon SL2has Canon battery -- paint peeling off flip-out screen
DSLR 81120 7101 2724Canon SL2has Canon battery
DSLR 91120 7101 2686Canon SL2has Canon battery
DSLR 101120 7101 2679Canon SL2has Canon battery
DSLR 111120 7101 2681Canon SL2has Canon battery

This would also allow you to filter the list and find only those that are out.
EDIT - sorry, I missed that you are trying to create a loan history. Perhaps using the vba sheet change event to copy over cells (not move as you stated)?
 
Upvote 0
Don't know if this will help you or not. Why don't you just have Check Out and Check In columns with dates? If there's no check in date, it's out.
ITEMSERIALMODELNOTESCHECK OUTCHECK INNAMEEMAIL
DSLR'S
DSLR 11520 3200 3461Canon T6ihas lens cap & Canon battery9/15/239/25/23mikemike@kkkkkkkk.com
DSLR 21520 3200 3464Canon T6ihas canon battery9/21/23
DSLR 31520 3200 3462Canon T6ihas lens cap & Canon battery
DSLR 4missing #Canon SL2has lens cap & Canon battery
DSLR 51120 7101 2723Canon SL2has lens cap & Canon battery
DSLR 61120 7101 2721Canon SL2has lens cap & Canon battery
DSLR 7# damagedCanon SL2has Canon battery -- paint peeling off flip-out screen
DSLR 81120 7101 2724Canon SL2has Canon battery
DSLR 91120 7101 2686Canon SL2has Canon battery
DSLR 101120 7101 2679Canon SL2has Canon battery
DSLR 111120 7101 2681Canon SL2has Canon battery

This would also allow you to filter the list and find only those that are out.
EDIT - sorry, I missed that you are trying to create a loan history.
We have a 24 hour policy so we need to know when it is checked out to enforce it. Just trying to figure out how to make an easy way to mark that it is checked in but then keep a history of who had in case there was an issue.
 
Upvote 0
See if you can make this work with some modifications
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim strWhat As String, strWho As String

Set rng = Intersect(Target, Range("E:E"))
If Not rng Is Nothing Then
     If Target = "IN" Then
          strWhat = Target.Offset(0, -3)
          strWho = Target.Offset(0, 2)
          'code to write who & what to some sheet would go here
     End If
End If

End Sub
No idea where you want to put what. Wherever it's going, I just guessed that it might be person name and item serial.
 
Upvote 0
See if you can make this work with some modifications
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim strWhat As String, strWho As String

Set rng = Intersect(Target, Range("E:E"))
If Not rng Is Nothing Then
     If Target = "IN" Then
          strWhat = Target.Offset(0, -3)
          strWho = Target.Offset(0, 2)
          'code to write who & what to some sheet would go here
     End If
End If

End Sub
No idea where you want to put what. Wherever it's going, I just guessed that it might be person name and item serial.
Thank you. I can semi understand what you did. Just not sure what is the What and Who? Basically, when the pull down is set to IN I want to take the name and email of the row and move it to another sheet, labeled history or something like that.

Also, is there a way if we set that up we can also copy paste something else in the same row to the other sheet?

Long version is when set to IN, Item is copied / pasted to new sheet and name and email is moved to same sheet?

I hope this makes sense.
 
Upvote 0
it will take the contents of one or two cells in that row and move it to another sheet
You're going to have to be a lot more specific than that if you want focused answers. Best I can do otherwise is answer with general statements/ideas. The who/what was explained.
No idea where you want to put what. Wherever it's going, I just guessed that it might be person name and item serial.


I now get why you want to move the values but how would this be very useful?
Basically, when the pull down is set to IN I want to take the name and email of the row and move it to another sheet, labeled history
 
Upvote 0
You're going to have to be a lot more specific than that if you want focused answers. Best I can do otherwise is answer with general statements/ideas. The who/what was explained.



I now get why you want to move the values but how would this be very useful?

It helps us with inventory. It is for students and if someone checks out a camera and say it is missing the lens cap, we can see who had it last to contact them. Thanks for the help, I am going to play around and see what I can do now
 
Upvote 0
Well I don't see how but if you say so. All I see there is who returned something but it doesn't show what it was.
 
Upvote 0
You're going to have to be a lot more specific than that if you want focused answers. Best I can do otherwise is answer with general statements/ideas. The who/what was explained.



I now get why you want to move the values but how would this be very useful?

OK, I got it working where it copies the name to the other sheet. WHat I need help with now is 2 things.

1. How do I set it to move the name instead of copy it?
2. How do I make it so everytime a new name is entered and the value is set to IN, the name moves to the next cell down in the new sheet?

I am so close, just need help to the finish line. I appreciate the help. Here's a link to the file
 
Upvote 0
Took a look. Doesn't look right to me. You should be running the code based on the choice of in or out, no? That would be column E as I showed you.
Simple enough to copy as you've done, then make the same cell = "". However, that would not be G4, it would be an offset of the target cell (whichever one was set to in or out) in the same row. What happens when G5 is set to IN? Your target value in the other sheet will be wiped out because G4 value was removed already.

What happened to the other values you wanted to copy over?
 
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,716
Members
449,464
Latest member
againofsoul

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