ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop thru excel columns (https://www.excelbanter.com/excel-programming/424286-loop-thru-excel-columns.html)

shantanu

Loop thru excel columns
 
Hi All

I want to loop thru the excel columns and insert multiple data
horizontally along the columns. Kindly help me with some logic or C#
code

Thanks
Shantanu

OssieMac

Loop thru excel columns
 

--
Regards,

OssieMac


"shantanu" wrote:

Hi All

I want to loop thru the excel columns and insert multiple data
horizontally along the columns. Kindly help me with some logic or C#
code

Thanks
Shantanu


Mike H

Loop thru excel columns
 
Hi,

Loop through columns and do what? Try this

Sub sonic()
lastcolumn = Cells.Find(What:="*", After:=[A1], _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

For x = 1 To lastcolumn

'insert lots of data


Next
End Sub

Mike

"shantanu" wrote:

Hi All

I want to loop thru the excel columns and insert multiple data
horizontally along the columns. Kindly help me with some logic or C#
code

Thanks
Shantanu


OssieMac

Loop thru excel columns
 
Hi Shantanu,

When I got the notification of a reply on this thread I see that my answer
was empty except for the auto sign off so here it is again.

The following loops through columns until it comes to a cell in row 1 that
is blank.

You could use a specific column number in lieu of Columns.Count.

I am not really sure what it is you want to do but hope the example helps to
point you in the right direction.

Sub loopThroughColumns()

Dim c As Long

For c = 1 To Columns.Count
If Cells(1, c) < "" Then
MsgBox "Cell " & Cells(1, c).Address
Else
MsgBox "No more data"
Exit For
End If
Next c
End Sub


--
Regards,

OssieMac




All times are GMT +1. The time now is 11:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com