how to insert column between q.

C

cy

I have 500+ question in a row,how can I insert column in between every
questions but there are some questions already inserted with column,is there
a method to save time so that each q. will have only 1 blank column in
between it?
 
T

Toppers

Given that Excel only has 256 columns, how can you have 500 questions in a row?
So do you mean columns?
 
G

Gord Dibben

cy

There are only 256 columns in Excel so 500+ is out of the question and inserting
even more columns is in the same category.

Perhaps re-think your question and re-post when more clear what you want to do.

Rows or Columns..........which is it?

Rows are 1,2,3,4,5 etc and Columns are A,B,C,D etc.


Gord Dibben MS Excel MVP
 
O

Otto Moehrbach

You must mean rows instead of columns.
Yes, VBA can do that, but Excel needs to know how to identify a line as
being the beginning of a new question. Pretend that you are explaining how
to do this to someone who doesn't know your data. What would you say to
him? HTH Otto
 
C

cy

you don't know what i mean?
let say i have 5q. in a row that is A1(q.1),A2(q.2),A3(q.3),A4(q.4),A5(q.5)
how can i insert a column next to each q. so that the seqence now is
A1(q.1),A2(blank),A3(q.2)........
but some blank columns have already inserted,so how to write that VBA?

"Otto Moehrbach" 來函:
 
C

cy

You are correct,Bryan i mix up column and row wrongly,and the answer is
partly correct only
..It is because like i said before,there are some blank rows already
inserted,after running the marco ,there will be 3 blank together,so is there
possible to rewrite the macro so that it will not adding a blank row before
and after the blank row that already exist?

"Bryan Hessey" 來函:
 
B

Bryan Hessey

If you have already started to insert blanks, then adjust the number
shown as Startrow= from 1 to the first row you need. (in Dave's code)

FirstRow = 1 'no headers
to
FirstRow = 25 'no headers - the number being your first desired row

To insert only 1 blank, amend

..Rows(iRow).Resize(2).Insert
to
..Rows(iRow).Resize(1).Insert

This should work.

---
 
C

cy

oh my..............my blanks is distributed randomly,so is there any method
to chg the code to avoid insert blank when matching blanks

"Bryan Hessey" 來函:
 
B

Bryan Hessey

try amending to:

For iRow = LastRow To FirstRow + 1 Step -1

If .Cells(iRow - 1, 1).Value = "" Then
iRow = iRow - 1
Else
..Rows(iRow).Resize(1).Insert
End If
Next iRow
 
O

Otto Moehrbach

No Cy, I don't know what you mean, that's why I asked the question.
Apparently, your data has one question per row. You failed to mention that.
You could have easily had questions that take up more than one row. How
would somebody other than you know that? Apparently my question offended
you. For that, I apologize. Otto
 
Top