mysticmario
Active Member
- Joined
- Nov 10, 2021
- Messages
- 323
- Office Version
- 365
- Platform
- Windows
Basically I have a vbYEsNO option when soemoen chooses yes the code exectues as intended, but when someone presses "no" the code also "half-***" executes(creates new sheet and adds some data)
First i only had vbYes and Else today i tried with vbYes vbNo and Else, but nothing seems to stop this pesky code from running. thsi is the code:
First i only had vbYes and Else today i tried with vbYes vbNo and Else, but nothing seems to stop this pesky code from running. thsi is the code:
VBA Code:
Private Sub kartarealizacji_Click()
MsgBox "Is the project already in the system?" & vbCrLf & "To properly generate material sheet project MUST be already in the system (ArtProInfo v1.5/Project List))", vbYesNo
If vbYes Then
LastSh = ActiveSheet.Name
Sheets("KARTA REALIZACJI").Visible = xlSheetVisible
Sheets("KARTA REALIZACJI").Copy after:=Sheets(Sheets.Count)
Sheets("KARTA REALIZACJI").Visible = xlSheetVeryHidden
ActiveSheet.Name = "Karta Realizacji projektu"
ProjectSh = ActiveSheet.Name
Sheets(LastSh).Activate
'EXPORT DANYCH'
Dim Rng As Range, cell As Range, lr As Long, i&, j&, mtr As Range, paint As Range
Sheets(ProjectSh).Range("D5") = Date
lr = 10
Set paint = ActiveSheet.Range("K39, K72, K105, K138, K171")
Set mtr = ActiveSheet.Range("E19, E52, E85, E118, E151")
Set Rng = ActiveSheet.Range("H195:H273")
For Each cell In mtr
If Not IsEmpty(cell) And cell.Value <> 0 Then
lr = lr + 1
Sheets(ProjectSh).Cells(lr, "B").Value = ("Płyta " & cell.Value)
Sheets(ProjectSh).Cells(lr, "C").Value = cell.Offset(20, 1).Value & "m2"
lr = lr + 1
If cell.Offset(20, 4).Value > 0 Then
Sheets(ProjectSh).Cells(lr, "B").Value = ("Obrzeże " & cell.Value)
Sheets(ProjectSh).Cells(lr, "C").Value = cell.Offset(20, 4).Value & "mb"
Else:
lr = lr - 1
GoTo nextcell
End If
End If
nextcell: Next cell
lr = lr + 2
For Each cell In paint
If Not IsEmpty(cell) And cell.Value <> 0 Then
Sheets(ProjectSh).Cells(lr, "B").Value = ("Lakier: " & "*WYMAGANY KOLOR*")
Sheets(ProjectSh).Cells(lr, "C").Value = cell.Value & "m2"
lr = lr + 1
Else:
lr = lr - 1
GoTo nextitem
End If
nextitem: Next cell
Call export_acc
If vbNo Then
MsgBox "You must first create a project in the system": Exit Sub
End If
Else
MsgBox "You must first create a project in the system": Exit Sub
End If
End Sub