PDA

View Full Version : Auto filling data w/ VBA



georgedixon
07-30-2018, 09:15 AM
Hi, I have essentially made a calendar on excel, with the Dates in column A the time slots that I have listed are in the corresponding columns (B--> L). I have now made a second page which I am attempting to program. On this page, I have used the "TODAY()" Function, to get todays date. I am attempting to make some code, which searches for Today's date in the schedule and returns all the items in each block to the new sheet (So I can look on the spreadsheet to see what I need to do each day without having to scroll through the big list).

I have used the following three 'modules' in an attempt to complete this task.


Private Sub Update()
Dim RowNumber2 As Integer
Dim RowNo As Integer
RowNumber2 = Sheets("Currently Owned").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
For i = 3 To RowNumber2
If Sheets("Sheet1").Range("A" & i) = Sheets("Sheet2").Range("A2") Then
RowNo = i
For j = 2 To 19
Number2Letter (j)
Sheets("Sheet2").Range(Number2Letter(j) & "2") = Sheets("Sheet1").Range(Number2Letter(j) & i)
End If
Next
End Sub

I believe my problem is coming in with the following bit of code. I feel I am misunderstanding how coding VBA works. I am used to coding w/ Python, and clearly my methods are not working.


Sub Number2Letter(ColumnNumber)
Dim ColumnNumber As Long
Dim ColumnLetter As String
'Convert To Column Letter
ColumnLetter = Split(Cells(1, ColumnNumber).Address, "$")(1)
Return ColumnLetter
End Sub




Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Call Update
End If
End Sub


If anyone could offer me a solution to my problem that'd be great