Wednesday, September 7, 2016

Can't figure out how to get my code to run the right way [Anwsered]

Can't figure out how to get my code to run the right way

Basically the start of my code checks the value in cell Y1.  From there it runs code, then at the end if the value was 1 in Y1 then it will change to 2 and visa versa.  Then the next time the code runs it will run the other ifThen statement.  I can't figure
out the way to do this.  I know it's just a matter of rearranging some lines. 
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
 Col = 3
If Range("Y1").Value = 1 Then
 If Target.Cells.Count > 1 Then Exit Sub
 If Not Intersect(Target, Range _
 ("Line1,Line2,Line3,Line4,Line5,Line6,Line7,Line8,Line9,Column1,Column2,Column3,Column4")) Is Nothing Then
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Application.EnableEvents = False
 
Target.Offset(0, 19).Value = 1
 
Application.EnableEvents = True
 Range("A1").Select
 Else
 'do nothing
  End If
 End If
 If Range("Y1").Value = 2 Then
 If Target.Cells.Count > 1 Then Exit Sub
 If Not Intersect(Target, Range _
 ("Line1,Line2,Line3,Line4,Line5,Line6,Line7,Line8,Line9,Column1,Column2,Column3,Column4")) Is Nothing Then
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 5287936
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Application.EnableEvents = False
 
Target.Offset(0, 19).Value = 2
 
Application.EnableEvents = True
 Range("A1").Select
 Else
 'do nothing
 End If
 End If
 
 If Range("Y1").Value = 1 Then
 Range("Y1").Value = 2
 Else: Range("Y1").Value = 1
 End If
 
 End Sub
 
If there is any way to shorten what I have that would be great.

Keys to the Problem Can't figure out how to get my code to run the right way

Download Error Fixer for Free Now

I think this is close...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim c As Range
    
    If Target.Cells.Count > 1 Then Exit Sub
    If Intersect(Target, Range _
     ("Line1,Line2,Line3,Line4,Line5,Line6,Line7," & _
      "Line8,Line9,Column1,Column2,Column3,Column4")) Is Nothing Then Exit Sub
    Col = 3 'not sure what this does
   
    Application.EnableEvents = False
   
    With Range("Y1")
    If .Value = 1 Then
        Target.Interior.Color = 255
        Target.Offset(0, 19).Value = 1
        Range("A1").Select
        .Value = 2
    ElseIf .Value = 2 Then
        Target.Offset(0, 19).Value = 2
        Range("A1").Select
        .Value = 1
    End If
    End With
   
    Application.EnableEvents = True
 End Sub

Running System Update Readiness Command

On running the System Update readiness Command, it will Detect & Replace Incorrect Registry data with the Correct one. Which may ultimately Solve Can't figure out how to get my code to run the right way in Windows.

  1. Open CMD as Administrator by Simply Right Clicking on Start button > Command Prompt (Admin).
  2. Now Type or Copy paste "DISM.exe /Online /Cleanup-image /Scanhealth" and hit Enter,
  3. Now again Type or Copy paste this "DISM.exe /Online /Cleanup-image /Restorehealth" and hit Enter.
  4. Close the Command Prompt Window because we are done.

Reboot your Windows & see if error Can't figure out how to get my code to run the right way still comes up.

Note: Your administrator's password might be needed.

Recommended Method to Repair the Problem: Can't figure out how to get my code to run the right way:

How to Fix Can't figure out how to get my code to run the right way with SmartPCFixer?

1. You can Download Error Fixer here. Install it on your system. When you open it, it will perform a scan.

2. After the scan is done, you can see the errors and problems which need to be repaired.

3. The Repair part is done, the speed of your computer will be much higher than before and the errors have been removed. You can also use other functions in SmartPCFixer. Like dll downloading, windows updating and print spooler error repair.


Related: How to Download Toshiba Satellite A205-S5833 Supervisor Password Utility v.1.48.0.8C r2 driver,How to Download Toshiba Satellite C675-S7104 Laptop Checkup v.2.0.13.11 driver,How Can I Update & Download Toshiba Satellite L655-S5117 Face Recognition v.3.1.3 driver,Method to Update & Download Toshiba Satellite L845D-SP4328KL Atheros LAN Driver v.2.1.0.5,How to Update & Download Toshiba Satellite R930 Network Device ID Registry Setting Tool v.3.0.32.4 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17,Way to Download RealTek RTL8100C(L) Driver v.5.01,Way to Download RealTek RTL8100E Drivers v.694,Way to Update & Download RealTek RTL8101L Auto Installation Program v.6.110 driver,Method to Update & Download RealTek RTL8111G PXE and RPL ROM code v.2.58 driver,How to Update & Download RealTek RTL8411B(N) Driver v.10.003,Best Way to Update & Download ASUS A53SV nVidia Graphics Driver v.8.17.12.6686,Method to Herunterladen ASUS K75VJ Intel Rapid Storage Technology Treiber v.11.6.0.1030,How Can You Update & Download ASUS CG8580 Intel Chipset Driver v.9.3.0.1019,Method to Update & Download ASUS K41VD Intel INF Update Driver v.9.1.1.1015,Way to Update & Download ASUS Pro70T NB Probe v.3.0.0026 driver
Read More: Can you network 2 systems running Windows 7, one 32 bit and the other 64 bit? [Solved],Troubleshoot:Can't find script engine "VBScript" for script webcam application,How to Fix Problem - CAN WORKS 2000 BE USED WITH WINDOWS 7??,Troubleshooting:Can't Download apps from Internet Error,Solution to Error: Can you suggest me which one to use graphic card for my desk top?,Can I safely remove earlier versions on my pc,Can I rotate a graph so it shows on my page sideways?,Can I safely ignore Office file validation alert message?,Can I send a JPEG file in a PDF form ?,can I review when my computer has been accessed from outside my home?

No comments:

Post a Comment