Thread: Macro question
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
tlee tlee is offline
external usenet poster
 
Posts: 40
Default Macro question

Hi all,

Thank you all of yours help.

Bernie,
As for the point 2, how can I specified to detect the Column A only, which
contains data, and then write the sequence number (e.g. 1.........9999) into
the specified column G (start from G2) automatically?

Because, I found that all another columns data are also changed to the same
value as column G.

I change your code from "A2" to "G2"
With Worksheets("Sheet1").Range("G2", Cells(Rows.Count,
1).End(xlUp)).Offset(0, 1)
.Formula = "=ROW()-1"
.Value = .Value
End With

Thanks
Tlee


TLee,

1)

Worksheets("Sheet1").Range("A:C").Copy Worksheets("Sheet2").Range("H:J")

2)

With Worksheets("Sheet1").Range("A2", Cells(Rows.Count,
1).End(xlUp)).Offset(0, 1)
.Formula = "=ROW()-1"
.Value = .Value
End With


HTH,
Bernie
MS Excel MVP


"tlee" wrote in message
...
Hello all,

Could anyone tell me about using Macro /VBA as below

1) How to copy several whole columns from one sheet to another sheet
within the same Excel file?
2) How to detect the column and fill the number into another column?
e.g. ColumnA2 to A99 contains data, then it can fill the number from
1,2,3,4,5.....................,97,98 into the column B2 to B99
automatically?

Thank you for your help first.

TLee