i need to build login text from a list in Excel. I try myself with macro and write a small script. basically i have 2 cell one next to the other. the first one get a ssh key name, and the second get the passphrase. this 2 value depend on the os of the machine, specified in an other field. Final i have a table with the os name, and the ssh key next to the passphrase.
this is what i wrote :
Function FindKey(FirstCell As Range) As String
'
' FindKey Macro
' Find the ssh key in function of the OS
'
Dim Find As Boolean
Dim Cell As Range
Dim OS As String
Cell = ActiveCell.Address
ActiveCell.Offset(0, 4).Value = OS
Find = False
While Not Find
ActiveCell = FirstCell.Address
If ActiveCell.Value = OS Then
FindKey = ActiveCell.Offset(0, 1).Value
Cell.Offset(0, 1).Value = ActiveCell.Offset(0, 2).Value
Cell.Select
Find = True
Else
ActiveCell.Offset(1, 0).Select
If IsEmpty(ActiveCell) Then
Cell.Select
FindKey = CVErr(xlErrNull)
Find = True
End If
End If
Wend
'
End Function
I truly have no idea of how I'm suppose to write that. Can i only store cell address in a variable ? can i use it as a object next ?
Thank you for your time and have a nice day
dim yourCell as Range
set yourCell = ActiveCell
and
set yourCell = FirstCell
You need to use the keyword set when setting an object reference
Set myActiveCell = ActiveCell
Set myActiveWorksheet = ActiveSheet
'Your code here
myActiveWorksheet.Activate
myActiveCell.Activate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.