Help With Error in VBA CODE

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
Hey I got a weird Problem with my Code (Clean Sheets Cells)

I have Picture on my sheets to press on and Macro Running as it should
everything in the Code Works ok BUT BUT
when the code is running from sheets 2 Clean Specific cells and then Jump on to sheets 1 and Clean specific cells as it should
and then Jump Back sheets 2


My Question is Now : is it Possibel to NOT see Sheet 1

My code is Here:
-------------------------------------------------------------------------------------------------------------------------------

Sub Nulstil2x7()
'
' Nulstil2x7 Makro
'
'
Range("AV31:AV32,AO43:AO44,AH49:AH50").Select
Range("AH49").Activate

Range("AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41").Select
Range("AA40").Activate

Range( _
"AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41,AH37:AH38,AA34:AA35,AA28:AA29,AH24:AH25" _
).Select
Range("AH24").Activate

Range( _
"AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41,AH37:AH38,AA34:AA35,AA28:AA29,AH24:AH25,AO18:AO19,AH10:AH11,AA21:AA22,AA13:AA14" _
).Select
Range("AA13").Activate

Range( _
"AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41,AH37:AH38,AA34:AA35,AA28:AA29,AH24:AH25,AO18:AO19,AH10:AH11,AA21:AA22,AA13:AA14,AA7:AA8,Q8:Q14" _
).Select
Range("Q8").Activate

Range( _
"AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41,AH37:AH38,AA34:AA35,AA28:AA29,AH24:AH25,AO18:AO19,AH10:AH11,AA21:AA22,AA13:AA14,AA7:AA8,Q8:Q14,Q29:Q35" _
).Select
Range("Q29").Activate

Range( _
"AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41,AH37:AH38,AA34:AA35,AA28:AA29,AH24:AH25,AO18:AO19,AH10:AH11,AA21:AA22,AA13:AA14,AA7:AA8,Q8:Q14,Q29:Q35,L35,K35,J35,I35,H35,G35,G34:K34,G33:J33,G32:I32,G31:H31,G30" _
).Select
Range("G30").Activate

Union(Range( _
"G10:H10,G9,AV31:AV32,AO43:AO44,AH49:AH50,AA52:AA53,AA46:AA47,AA40:AA41,AH37:AH38,AA34:AA35,AA28:AA29,AH24:AH25,AO18:AO19,AH10:AH11,AA21:AA22,AA13:AA14,AA7:AA8,Q8:Q14,Q29:Q35,L35,K35,J35,I35,H35,G35,G34:K34,G33:J33,G32:I32,G31:H31,G30,G14:L14,G13:K13" _
), Range("G12:J12,G11:I11")).Select
Range("G9").Activate

Sheets("Lodtrækning").Select
Range("A1:A20,B1:B20").Select

Application.CutCopyMode = False
Selection.ClearContents

Sheets("2 X 7 X antal videre").Select
Selection.ClearContents
Range("Q8").Select
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi

In your code, you're selecting one sheet then you're selecting another sheet … Check the below lines in your code

Rich (BB code):
' some code here
'
'
' then this line selects one sheet
 Sheets("Lodtr?kning").Select
'
'
' then this line selects another sheet
 Sheets("2 X 7 X antal videre").Select
'
'
'rest of code here
 
Upvote 0
Hi MSE330

Yes i Know those line where in my Code
that is instead of first Click on a Bottom Clean Sheets "2 X 7 X Antal videre" and then goto
Sheet "Lodtrækning" and click on a Bottom Clean Sheets "Lodtrækning" and then go back to the Sheets "2 X 7 X Antal videre"
 
Upvote 0
If you don't want to see the other sheet, don't select it instead just use something like the below

Code:
Sheets("2 X 7 X Antal videre").Range("A1:B10").ClearContents
 
Upvote 0
Try to add the below two lines to your code & see if it helps

Code:
Sub ABC()
'
Application.ScreenUpdating = False
'
' your code here
'
Application.ScreenUpdating = True
'
End Sub
 
Upvote 0
You are welcome .. Glad to help & thanks for reporting back :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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