Tuesday 5 November 2019

excel - How do I avoid the select in VBA. Need to to have Main as visible and other sheets hidden

How do I avoid the select in VBA. Need to to have Main as visible and other sheets hidden. Below are the codes I am currently using:




    Sub Run_Historical()

'Application.ScreenUpdating = False
Dim skillit As String
Dim nowsever As String
Dim CMSReport As String
Dim username As String
Dim pword As String
Dim setdate As String
Dim reportlocation As String


'Clear Data

Sheets("CMSRaw").Select
Range("A2:BX1500").Select
Selection.ClearContents


Sheets("Reference").Select
skillit = Range("B6").Value

Range("B6").Select
Do While Not IsEmpty(ActiveCell.Value)
nrow = ActiveCell.Row
skillit = ActiveCell.Value
nowserver = Range("C" & nrow).Value
reportlocation = Range("H" & nrow).Value


Remaining of the codes are still having select sheets and cells which slows my PC as I am running a lot of application.




CMSReport = Range("D" & nrow).Value
setdate = Range("G" & nrow).Value
reportit = Range("D" & nrow).Value
originaladdress = ActiveCell.Address

'Function CMSConn(sUserID As String, sPassword As String, sServerIP As String, sSkill As String, sDate As String, sReport)

Call CSSConn2(username, pword, Range("C" & nrow).Value, skillit, setdate, reportit, reportlocation)
originalsheets = ActiveSheet.Name
pastecell = Range("F" & nrow).Value

Sheets(Range("E" & nrow).Value).Select
Range(pastecell).Select

ActiveSheet.Paste
Sheets(originalsheets).Select
Range(originaladdress).Select
Range("A" & nrow).Value = Now()
ActiveCell.Offset(1, 0).Select



If ActiveCell.Value = "" Then
MsgBox "Done"
ThisWorkbook.Activate
Sheets("MainPage").Select
Range("A1").Select
Exit Sub
End If
Loop
'MsgBox "CMS data has been extracted", vbOKOnly


Application.ScreenUpdating = False


End Sub

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...