Description

Excel discussions

Excel VBA password

Forums

Sub excelvbapassword()
    'Breaks worksheet password protection.
 
    Dim i As Integer, j As Integer, k As Integer
    Dim l As Integer, m As Integer, n As Integer
    Dim i1 As Integer, i2 As Integer, i3 As Integer
    Dim i4 As Integer, i5 As Integer, i6 As Integer
 
    On Error Resume Next
 
    For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
    For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
    For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66

How to use a cell value from another excel file inside Excel VBA

Forums

Here we have D:\data.xlsx which is saved in D Drive, to access the value  of B4 of Sheet1 of this file from another excel VBA, please add below code

Dim wkbk1 As Workbook
Set wkbk1 = Workbooks.Open("D:\data.xlsx")
Dim cellvalueofdatafile As Variant
cellvalueofdatafile = wkbk1.Sheets("Sheet1").Range("B" & 4)
wkbk1.Close

now we have the cell value of B4 (of D:\data.xlsx, Sheet1) in the variable cellvalueofdatafile which can be used for other calculations

 

How to use a cell value from another excel file inside Excel VBA

Forums

Here we have D:\data.xlsx which is saved in D Drive, to access the value  of B4 of Sheet1 of this file from another excel VBA, please add below code

Dim wkbk1 As Workbook
Set wkbk1 = Workbooks.Open("D:\data.xlsx")
Dim cellvalueofdatafile As Variant
cellvalueofdatafile = wkbk1.Sheets("Sheet1").Range("B" & 4)
wkbk1.Close

now we have the cell value of B4 (of D:\data.xlsx, Sheet1) in the variable cellvalueofdatafile which can be used for other calculations

 

My notes for excel vba

Forums

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim nRow As Long, d As Double
On Error GoTo errH
If Target.Count = 1 And Target(1).Column > 3 Then
If LCase(Target.Value) = ("multiply") Then
Application.EnableEvents = False
nRow = Target.Row
d = Cells(nRow, 2).Value * Cells(nRow, 1).Value
If d Then
Target.Value = d
Else: Target.Value = ""
End If
End If
End If

errH:
Application.EnableEvents = True
End Sub