1

I need to work on cell by activating it but another cell in another sheet being shown, so before showing the userform ScreenUpdating is set to false. in the userform when one check box is selected below code will run to switch between sheets so that some data be selected from sheet1 and then showing sheet2 while the previous cell is still activated. These are the sheets i need to switch between

Application.ScreenUpdating = True
Sheets("Sheet1").Select

Set rRange = Application.InputBox(Prompt:= _
               "Please select the Ticket ID with your Mouse.", _
                   Title:="Title", Default:="", Type:=8)
Sheets("Sheet2").Activate

Application.ScreenUpdating = false

Sheets("Sheet1").Activate  ' previous cell row number is stored in Sheets("Sheet2").Range("A1")
Sheets("Sheet1").Cells(Sheets("Sheet2").Range("A1").Value, Sheets("Sheet1").Rows(1).Find("head1", , xlValues, xlWhole).Column).Activate
  • 1
    ...maybe you add some screenshots to clarify! – DisplayName Oct 23 '19 at 12:46
  • Step 1: [Avoid Using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) Step 2: Funnily enough, `Application.ScreenUpdating = True` sets Screen Updating to `True`, not `False`. Then you shows your InputBox, and (**after** the InputBox has opened, been used, and been closed) *then* you are setting `Application.ScreenUpdating = false` – Chronocidal Oct 23 '19 at 12:48
  • 2
    @Chronocidal: I am against using things like `Select` but I think this is one of the very few instances where `Select` is probably needed as OP is selecting sheets so that user can select a range from `Sheet1`. This is the reason why OP is also setting screen updating to **true**. Saying that, I am with DisplayName!.. I have no idea what OP's query is – Zac Oct 23 '19 at 13:21
  • @Chronocidal: I need to have data changing and keeping between "all subs" in the cell, the best way was to use select. the point is this to update screen to true then false so that user can select from another sheet and then back to sheet2 and showing sheet2 while a cell in sheet1 is active – Mahdi Abadinia Oct 23 '19 at 13:35
  • Still not clear on your query. Are you saying that once you set screen updating to `False`, screen is still showing what you are doing on `Sheet2`? – Zac Oct 23 '19 at 14:00
  • @Zac yes, when I set screen updating to false still screen updates as code goes. I also added screen shot of sheets. – Mahdi Abadinia Oct 23 '19 at 14:12
  • 1
    My understanding is that `.activate` and `.select` will immediately turn screen updating back on. Right after you set `.screenupdating = false` you use `.activate` which means, yes, you will see that screen flicker. – Cyril Oct 23 '19 at 14:15
  • @Cyril: I used this trick once, and worked fine the exact code runs by "UserForm_Initialize" – Mahdi Abadinia Oct 23 '19 at 14:40
  • Not sure why you need to `Activate` the cell? You already have access to the cell via VBA – Zac Oct 23 '19 at 15:39
  • @Zac I need to have data changing and keeping the data and format cell between "all subs" – Mahdi Abadinia Oct 26 '19 at 10:16

0 Answers0