How to get Column and row number of a calendar date - excel

How to get Column and row number of a calendar date in excel?
Eg. Suppose my date is 26-May-17 so I should get rownumber=5 and column number=5

As I understand you are having dates from Jan1 in cell A1 till Jan 31 in cell A31 and similarly Feb1 in cell B1 till Feb 28 in cell b28, So this way you can use the below code.
Sub test()
MsgBox ActiveCell.Address(0, 0, xlR1C1)
End Sub

Related

How to add two columns in one row till the end of the sheet

I am trying to take the sum of numbers. In "Oracle" sheet there is 1st Jan date column.so, I want to take the sum of column D3 and Column D4 in "Sheet2" sheet. Same as for 2nd Jan it will take sum of column D5 and D6. When I record the macro so and drag the same formula down so it was taking sum of D3 and D4 for 1st Jan, D4 and D5 for 2nd Jan and so on.
I want the sum of 1st jan column from "Oracle" sheet to "Sheet2" D2 column and the code will run till the last row because I have yearly data.
Please guide me how can I resolve this issue. Thank you in advance.
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveCell.FormulaR1C1 = "=ORACLE!R[4]C[-36]+ORACLE!R[5]C[-36]"
ActiveCell.Offset(1, 0).Range("A1:A2").Select
ActiveCell.FormulaR1C1 = "=ORACLE!R[4]C[-36]+ORACLE!R[5]C[-36]"
ActiveCell.Range("A2").Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:A10"), Type:= _
xlFillDefault
ActiveCell.Range("A1:A10").Select
End Sub

How to write a conditional range for the Command Button in Excel

I want to create a Command button in Excel which would add 1 to the value of cell A1 if you click it on Monday, add 1 to the value of cell B1 if you click it on Tuesday, add 1 to the value of cell C1 if you click it on Wednesday, add 1 to the value of cell D1 if you click it on Thursday, and finally add 1 to the value of cell E1 if you click it on Friday. Is it possible at all? What code should be used?
Thanks.
Use the Weekday function on Date (today), with Monday specified as the first day of the week.
Sub Test()
Dim wkDay As Long
wkDay = Weekday(Date, vbMonday)
With Cells(1, wkDay)
.Value = .Value + 1
End With
End Sub

converting excel spanish dates

I have spreadsheet with mutliple rows in which a few are dates. The problem is that while some rows are in english date format, few others are in spanish format eg. Octubre 1, 2015, Septiembre 1, 2014 etc. What could be the easiest way to convert all of them into english format dates.
Give this small macro a try:
Sub Converter()
ary = Split("Enero, January, Febrero, February, Marzo, March, Abril, April, Mayo, May, Junio, June, Julio, July, Agosto, August, Septiembre, September, Octubre, October, Noviembre, November, Diciembre, December", ", ")
For I = 0 To 23 Step 2
Cells.Replace What:=ary(I), Replacement:=ary(I + 1)
Next I
End Sub
The following sub will select all cells containing dates (irrespective of how they are formatted) on the active sheet. If you run it and then right-click on one of the selected cells and select format cells from the drop-down menu, you can decide on a common date format:
Sub SelectDates()
Dim dates As Range
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If IsDate(cell.Value) Then
If dates Is Nothing Then
Set dates = cell
Else
Set dates = Union(dates, cell)
End If
End If
Next cell
dates.Select
End Sub

Auto count by entering number in MS Excel

I am looking an excel sheet to calculate the total count by automatically.
I am creating an excel for attendance management system. There are about 30 students in the class. They are denoted by their registration number (2011/V/01,
2011/V/02, ...., 2011/V/30). They have many classes everyday. The attendance (every students put signature in the attendance sheet) is taken every hours by the lecturers. When the attendance sheets reached to the department, the officer ready to calculate the absentees.
The officer'll type the last number of the registration number for the absent students(Ex: 05 for 2011/V/05).
On starts the total absents is in zero.
When he/she inputs the last number in cell A3 and press enter, immediately the correspondent cell should increment by 1.
In first attendance sheet, registration number of 2011/V/02, 2011/V/05, 2011/V/07 and 2011/V/13 are absents
(Ex: cell A3 = 02 then cell D3 from 0 to 1).
(Ex: cell A3= 05 then cell D6 from 0 to 1).
(Ex: cell A3 = 07 then cell D8 from 0 to 1).
(Ex: cell A3 = 13 then cell D14 from 0 to 1).
In second attendance sheet 2011/V/03, 2011/V/05, 2011/V/13, 2011/V/16 and 2011/V/21 are absents
(Ex: cell A3 = 03 then cell D4 from 0 to 1).
(Ex: cell A3 = 05 then cell D6 from 1 to 2). (absent in first sheet,so 1 to 2)
(Ex: cell A3 = 13 then cell D14 from 1 to 2). (absent in first sheet,so 1 to 2)
(Ex: cell A3 = 16 then cell D17 from 0 to 1).
(Ex: cell A3 = 21 then cell D22 from 0 to 1).
In third attendance sheet 2011/V/03 and 2011/V/05 are absents
(Ex: cell A3 = 03 then cell D4 from 1 to 2). (absent in second sheet,so 1 to 2)
(Ex: cell A3 = 05 then cell D6 from 2 to 3). (absent in second sheet,so 2 to 3)
This'll happen every day until the attendance sheets is computerized.
https://www.flickr.com/gp/93604880#N02/8kv3N0
In the code module for the data-entry sheet:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim student As String, f As Range
If Target.Cells.Count = 1 And Target.Address() = "$A$3" Then
student = "2011/V/" & Format(Target.Value, "00")
Set f = Me.Range("C:C").Find(what:=student, lookat:=xlWhole)
If Not f Is Nothing Then
Me.Range("A3:A4").ClearContents
f.Offset(0, 1).Value = f.Offset(0, 1).Value + 1
Else
Me.Range("A4").Value = "Student not found!"
End If
Me.Range("a3").Select
End If
End Sub
what you want to do is best achieved with a very simple data entry user form.
Google "excel vba data entry user form" and you will found excellent tutorials.
Follow them and come back here to keep reading this answer.
I would create two sheets and one form.
Sheet1 would contain a log of your data entry. With just two columns, date and student code.
Sheet2 would contain the absences count. Again with two columns, column one the list of all of your students and colum two the running count of absences.
Form would contain two controls. One, a single field for the student code (either a text box or, something more elaborate like a combo box, built at initialize time with all the student codes of column 1 of sheet2). And two, a submit button.
On the code for the submit button, you should add some code to take the current date and selected student code, and insert them to the last row of sheet1.
On sheet2, the second column would be a formula, that is simply a count of the lookup results of the corresponding student code into the column 2 of sheet1.

VBA or Excel Macro to add 1year

I have an Excel Spreadsheet that I want to add 1 year to the date in a cell.
Cell B3 currently has a value of 1/1/2014
Would like to create a Macro that will change this date to 1/1/2015
Seems easy enough but my search for this have not given desired results. Any help would be appreciated.
Select your cell and run:
Sub dateFixer()
Dim d As Date
d = ActiveCell.Value
ActiveCell.Value = DateSerial(Year(d) + 1, Month(d), Day(d))
End Sub

Resources