G
Guest
Gents,
I'm currently using a script that opens excel and adds a line to the first
empty cell.
How can I expand this to : if the name (strmyinput) is already on that list,
add it to the same row on a new column instead of on a new row?
here's the script I got:
Sub bootstart()
strmyinput = InputBox("recruitname?")
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oWbks = oExcel.Workbooks
Dim ws As Excel.Worksheet
Dim wb As Excel.Workbook
Dim rn As Excel.Range
Set wb = oWbks.Open("C:\Documents and Settings\Overlord\My
Documents\Bart\TEAMSPEAK.xls")
Set ws = wb.Worksheets("Recruits")
Set rn = ws.Columns(1).Find("*", , xlValues, xlWhole, xlByRows, xlPrevious)
If Not rn Is Nothing Then
Set rn = rn.Offset(1, 0)
rn.Value = strmyinput
Set rn = rn.Offset(0, 1)
rn.FormulaR1C1 = "=TODAY()"
Else
' the last row (65536) isn´t empty
End If
wb.Save
wb.Close
Excel.Application.Quit
End Sub
I tried with Set rn = ws.Columns(1).Find("*" or strmyinput, , xlValues,
xlWhole, xlByRows, xlPrevious) but that didn't work.
any ideas anyone?
Thx!
I'm currently using a script that opens excel and adds a line to the first
empty cell.
How can I expand this to : if the name (strmyinput) is already on that list,
add it to the same row on a new column instead of on a new row?
here's the script I got:
Sub bootstart()
strmyinput = InputBox("recruitname?")
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oWbks = oExcel.Workbooks
Dim ws As Excel.Worksheet
Dim wb As Excel.Workbook
Dim rn As Excel.Range
Set wb = oWbks.Open("C:\Documents and Settings\Overlord\My
Documents\Bart\TEAMSPEAK.xls")
Set ws = wb.Worksheets("Recruits")
Set rn = ws.Columns(1).Find("*", , xlValues, xlWhole, xlByRows, xlPrevious)
If Not rn Is Nothing Then
Set rn = rn.Offset(1, 0)
rn.Value = strmyinput
Set rn = rn.Offset(0, 1)
rn.FormulaR1C1 = "=TODAY()"
Else
' the last row (65536) isn´t empty
End If
wb.Save
wb.Close
Excel.Application.Quit
End Sub
I tried with Set rn = ws.Columns(1).Find("*" or strmyinput, , xlValues,
xlWhole, xlByRows, xlPrevious) but that didn't work.
any ideas anyone?
Thx!