insert columns n times

luvbite38

Active Member
Joined
Jun 25, 2008
Messages
368
<TABLE style="WIDTH: 158pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=211><COLGROUP><COL style="WIDTH: 158pt; mso-width-source: userset; mso-width-alt: 7716" width=211><TBODY><TR style="HEIGHT: 22.5pt; mso-height-source: userset" height=30><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 158pt; HEIGHT: 22.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=30 width=211>Hi,</TD></TR><TR style="HEIGHT: 22.5pt; mso-height-source: userset" height=30><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 22.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=30>Can someone kindly help me fix the following code pls.
HTML:
Sub InsertMembers()
Dim y As Integer
  y = Application.InputBox("Number of members", "Number of members", Type:=1)
  If y > 50 Then MsgBox ("The maximum no. of members should NOT be over 50")
Range("V7").Select
  If y <= 50 Then
  ActiveCell.EntireColumn.Copy
    Range(ActiveCell.Offset(1), ActiveCell.Offset(y)).EntireColumn.Insert
     Application.CutCopyMode = False
     End If
End Sub
</TD></TR><TR style="HEIGHT: 22.5pt; mso-height-source: userset" height=30><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 22.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=30>This code is suppose to add columns n times. However, it is only adding one column for some reasons? Any idea to make it work plssssssss

thanks in advance
</TD></TR><TR style="HEIGHT: 22.5pt; mso-height-source: userset" height=30><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 22.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=30>Regards,</TD></TR><TR style="HEIGHT: 22.5pt; mso-height-source: userset" height=30><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 22.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl63 height=30>A</TD></TR></TBODY></TABLE>
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try below. Have not tested it.

Code:
Sub InsertMembers()
Dim y As Integer
  y = Application.InputBox("Number of members", "Number of members", Type:=1)
  If y > 50 Then MsgBox ("The maximum no. of members should NOT be over 50")
Range("V7").Select
  If y <= 50 Then
  ActiveCell.EntireColumn.Copy
    Range(ActiveCell.Offset(1), ActiveCell.Offset(1)).Resize(, y).EntireColumn.Insert
     Application.CutCopyMode = False
     End If
End Sub

Biz
 
Upvote 0
I tried and I don't get any errors. Have you protected your worksheet?

Biz
 
Upvote 0
dude, you were right.... it is working..... idk why it gave me the error when I ran it the first tym..................

my apologies............


Kindest ever regards for sorting me out.....

Ta
 
Upvote 0
dude, you were right.... it is working..... idk why it gave me the error when I ran it the first tym..................

my apologies............


Kindest ever regards for sorting me out.....

Ta

Kwel (y)

Biz
 
Upvote 0

Forum statistics

Threads
1,216,728
Messages
6,132,363
Members
449,720
Latest member
NJOO7

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