Workbook Events - Workbook New Sheet event

Excel VBA for Beginners Events in Excel VBA
2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€85.31
List Price:  €119.43
You save:  €34.12
£73.80
List Price:  £103.32
You save:  £29.52
CA$137.09
List Price:  CA$191.93
You save:  CA$54.84
A$153.07
List Price:  A$214.31
You save:  A$61.23
S$127.58
List Price:  S$178.62
You save:  S$51.03
HK$784.90
List Price:  HK$1,098.89
You save:  HK$313.99
CHF 79.84
List Price:  CHF 111.79
You save:  CHF 31.94
NOK kr1,007.62
List Price:  NOK kr1,410.71
You save:  NOK kr403.09
DKK kr636.42
List Price:  DKK kr891.01
You save:  DKK kr254.59
NZ$165.12
List Price:  NZ$231.17
You save:  NZ$66.05
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,224.06
List Price:  ৳17,114.18
You save:  ৳4,890.11
₹8,550.05
List Price:  ₹11,970.41
You save:  ₹3,420.36
RM422.80
List Price:  RM591.94
You save:  RM169.14
₦154,358.56
List Price:  ₦216,108.16
You save:  ₦61,749.60
₨28,364.66
List Price:  ₨39,711.66
You save:  ₨11,347
฿3,243.43
List Price:  ฿4,540.94
You save:  ฿1,297.50
₺3,990.56
List Price:  ₺5,586.94
You save:  ₺1,596.38
B$548.56
List Price:  B$768.01
You save:  B$219.44
R1,787.57
List Price:  R2,502.67
You save:  R715.10
Лв167.08
List Price:  Лв233.92
You save:  Лв66.83
₩136,432.45
List Price:  ₩191,010.89
You save:  ₩54,578.43
₪338.46
List Price:  ₪473.87
You save:  ₪135.40
₱5,656.23
List Price:  ₱7,918.95
You save:  ₱2,262.72
¥14,600.03
List Price:  ¥20,440.62
You save:  ¥5,840.59
MX$1,882.31
List Price:  MX$2,635.31
You save:  MX$753
QR364.02
List Price:  QR509.64
You save:  QR145.62
P1,336.26
List Price:  P1,870.82
You save:  P534.55
KSh12,948.70
List Price:  KSh18,128.70
You save:  KSh5,180
E£4,968.49
List Price:  E£6,956.09
You save:  E£1,987.59
ብር13,523.64
List Price:  ብር18,933.64
You save:  ብር5,410
Kz91,690.83
List Price:  Kz128,370.83
You save:  Kz36,680
CLP$93,095.40
List Price:  CLP$130,337.28
You save:  CLP$37,241.88
CN¥717.17
List Price:  CN¥1,004.07
You save:  CN¥286.90
RD$5,954.40
List Price:  RD$8,336.40
You save:  RD$2,382
DA12,900.28
List Price:  DA18,060.91
You save:  DA5,160.62
FJ$224.15
List Price:  FJ$313.82
You save:  FJ$89.67
Q768.66
List Price:  Q1,076.16
You save:  Q307.49
GY$20,901.47
List Price:  GY$29,262.89
You save:  GY$8,361.42
ISK kr12,112.24
List Price:  ISK kr16,957.62
You save:  ISK kr4,845.38
DH904.53
List Price:  DH1,266.38
You save:  DH361.85
L1,679.80
List Price:  L2,351.79
You save:  L671.99
ден5,247.92
List Price:  ден7,347.31
You save:  ден2,099.38
MOP$808.22
List Price:  MOP$1,131.55
You save:  MOP$323.32
N$1,786.82
List Price:  N$2,501.62
You save:  N$714.80
C$3,679.63
List Price:  C$5,151.63
You save:  C$1,472
रु13,674.86
List Price:  रु19,145.35
You save:  रु5,470.49
S/354.75
List Price:  S/496.66
You save:  S/141.91
K413.30
List Price:  K578.64
You save:  K165.34
SAR375.01
List Price:  SAR525.03
You save:  SAR150.02
ZK2,366.25
List Price:  ZK3,312.84
You save:  ZK946.59
L433.54
List Price:  L606.98
You save:  L173.43
Kč2,109.95
List Price:  Kč2,954.02
You save:  Kč844.06
Ft34,044.77
List Price:  Ft47,664.04
You save:  Ft13,619.27
SEK kr948.80
List Price:  SEK kr1,328.36
You save:  SEK kr379.56
ARS$118,751.94
List Price:  ARS$166,257.47
You save:  ARS$47,505.52
Bs690.60
List Price:  Bs966.86
You save:  Bs276.26
COP$403,743.24
List Price:  COP$565,256.70
You save:  COP$161,513.45
₡50,409.70
List Price:  ₡70,575.60
You save:  ₡20,165.89
L2,614.73
List Price:  L3,660.73
You save:  L1,045.99
₲797,587.30
List Price:  ₲1,116,654.13
You save:  ₲319,066.82
$U4,019.51
List Price:  $U5,627.48
You save:  $U1,607.96
zł361.83
List Price:  zł506.57
You save:  zł144.74
Already have an account? Log In

Transcript

Hey guys, welcome back. So in this video we're going to discuss the workbook, a new sheet event. So the workbook new sheet event runs whatever code you put in it whenever you insert in you sheet. So you can get out of course by opening your VBA editor double clicking on this workbook. And from this menu, you're going to select workbook and from this menu, we're going to select new sheet. So whatever code you put in, it will be run whenever you insert a new sheet.

So for example, I could put a message box you have inserted a new sheet. Okay, so now whenever we insert a new sheet, let's just insert a new sheet here. You can see here that the message box pops up, you have inserted a new sheet and actually this code runs after the sheet is inserted. So actually, the sheet is inserted first and then the code runs. Something else that we need to learn about is actually the S h parameter. Okay, and the SH parameter is basically a worksheet object, and it refers to the worksheet this just been inserted.

Okay? So something else that you can do is that you could give each new sheet inserted a number, okay, so for example, if we insert a new sheet in our case here, because it's going to be the fifth sheet in the workbook, it's going to be assigned the number five. So you can do this you could write sh dot name equals this workbook dot worksheets dot count. Okay, so now is going to be given the number five, or actually each sheet insert is going to be having a number that is going to be equal to the number of worksheets that would be available after inserting the new worksheet. So for example, let's insert a new sheet here. And series has been given the number five that's inserted.

Another one has been given a number six, because it's the sixth and let's insert a third one. It's going to give him the number seven because it's the seven okay? So this is the workbook new sheet event, I typically don't use that a lot. But if there is something in your business or something in your applications that you would require it for it's there, you know how to use it. Okay? And if you find something that this event would be really useful for and you liked it, please let me know about it.

Let me know about what application you use it for, you would be interested. So that's it for the workbook view sheet event. Thank you very much for watching this video. I'll see you on the next one.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.