looking to automate time and text entries

detweiler

Board Regular
Joined
Aug 2, 2013
Messages
60
I use a workbook to track the requests I receive & process, as well as everything else I do in a given day so that at the end of the week I can refresh the pivot table to use the totals to report on. It's a bit of an archaic system I report into with categories and related activities and was looking around to find how to automate the text entries into the worksheet based on the category, related activity and optional reference.

1588365700998.png


I was able to get the text piece to work in the specific / wanted cells, but ran into a snag when looking to adding time as part of the macro. The bigger snag, because I don't know best coding practices, is where I read on a couple of pages how using the Select or Selection function is not the best way to do what I'm wanting to do, but then really didn't describe the best way to accomplish what I'm trying to without doing that. So, here's what I had come up with the piece for the time entry -- note here about that, I thought it odd that after I typed in Time, the editor changed it to time.

VBA Code:
Sub CatOneActOneStart()
     Cells(Selection.Row, "B").Select
          Selection.Value = time
     ActiveCell.Offset(0, 1).Select
         Selection.Value = "csActivity"
     ActiveCell.Offset(0, 1).Select
         Selection.Value = "dept activities"
     ActiveCell.Offset(0, 1).Select
         Selection.Value = ""
End Sub

So, it's a two parter --
  1. If there's a better way of doing, can you please show me?
  2. Any idea why the editor changed Time to time and how do I get the current time to be inserted in the cell?
As is the usual, thanks for any assistance, guidance, help and insight.
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You could use
VBA Code:
Cells(Selection.Row, "B").Value = Time
to avoid selection of the cells that you're changing, with the same applied to the other cells by changing "B" to "C", etc instead of using Offset.

If Time is being changed to time then it suggests that you have declared time as variable somewhere with scope to this procedure, which is overriding the vba command. It is best not to use command names as variable names in order to avoid such issues.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,620
Messages
6,120,559
Members
448,970
Latest member
kennimack

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