Apply code to latest version

Status
Not open for further replies.

Nlhicks

Active Member
Joined
Jan 8, 2021
Messages
264
Office Version
  1. 365
Platform
  1. Windows
Sub FindRightRow1()

'Call NewestFile("c:\\Documents\Ratings\")


Application.ScreenUpdating = False

Dim LineUpdate As Worksheet, Sheet2 As Worksheet
Dim Ws As Range
Dim Rowz As Integer
Dim Wb As Workbook

Windows("WAPA-UGPR Facility Rating and SOL Record (Master).xlsm").Activate

This code works when I have both workbooks open and the names do not change. However, when I finish running this full code I save the workbook with the next version number so it will become v160.
I want to open the latest version and have this code work on that version. How can I make it so that version numbers do not matter in the workbook name?




Sheets("Line Update").Activate
Set LineUpdate = Sheets("Line Update")

Set Wb = Workbooks.Open("WAPA-UGPR Facility Rating and SOL Record (Data File)_v159.xlsx")
Wb.Sheets("Facility Ratings & SOLs (Lines)").Activate
Set Sheet2 = Sheets("Facility Ratings & SOLs (Lines)")
Set Ws = Sheet2.UsedRange

With Sheet2.Range("A1")
If LineUpdate.Range("D5").Value <> "" Then
Sheets("Facility Ratings & SOLs (Lines)").Activate
.AutoFilter field:=10, Criteria1:="*" & LineUpdate.Range("D5") & "*"
End If
If LineUpdate.Range("D6").Value <> "" Then
.AutoFilter field:=11, Criteria1:="*" & LineUpdate.Range("D6") & "*"
End If
If LineUpdate.Range("D7").Value <> "" Then
.AutoFilter field:=37, Criteria1:="" & LineUpdate.Range("D7") & ""
End If

Rowz = Application.WorksheetFunction.Subtotal(3, Range("A2:A686" & Rows(Rows.Count).End(xlUp).Row))
Debug.Print Rowz
'

If Rowz <= 1 Then

LineUpdate.Range("C11").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("B2:B695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C12").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("C2:C695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C13").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("D2:D695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C14").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("E2:E695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C15").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("F2:F695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C16").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("G2:G695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C17").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("H2:H695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C18").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("I2:I695").SpecialCells(xlCellTypeVisible)

GoTo Skip

ElseIf Rowz > 1 Then GoSub Item_Open
Wb.Sheets("Facility Ratings & SOLs (Lines)").Activate
.AutoFilter field:=36, Criteria1:=LineUpdate.Range("H6")

LineUpdate.Range("C11").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("B2:B695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C12").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("C2:C695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C13").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("D2:D695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C14").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("E2:E695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C15").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("F2:F695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C16").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("G2:G695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C17").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("H2:H695").SpecialCells(xlCellTypeVisible)
LineUpdate.Range("C18").Value = Wb.Sheets("Facility Ratings & SOLs (Lines)").Range("I2:I695").SpecialCells(xlCellTypeVisible)

Skip:
End If

End With

Exit Sub

Item_Open:

Dim sValue As String

Windows("WAPA-UGPR Facility Rating and SOL Record (Master).xlsm").Activate
Sheets("Line Update").Activate

sValue = Application.InputBox("Enter the TO: Bus Number here, Thank you.")
Worksheets("Line Update").Range("H6").Value = sValue
Debug.Print sValue
Return
Application.ScreenUpdating = True

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Duplicate to: Find the latest version

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top