Hello
I am trying to get values(Names) of a single row and with its respective columns from different worksheets
I am not able to get part of msg in Msg box as it only displays that part of Last sheet ie data of first few sheets with names and column numbers and not able to display but displays the same in last sheet
Regds
SamD
124
I am trying to get values(Names) of a single row and with its respective columns from different worksheets
I am not able to get part of msg in Msg box as it only displays that part of Last sheet ie data of first few sheets with names and column numbers and not able to display but displays the same in last sheet
VBA Code:
Private Sub CommandButton1_Click()
Dim wks As Worksheet
Dim cl As Range, msg As String, RowNumber as Long
Dim FirstColNumberSngRow As Integer, ColValStr As String, j As Integer
For Each wks In Worksheets
RowNumber = 3
Set cl = wks.Cells.Find(What:="*", _
After:=Cells(RowNumber, Columns.Count), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
FirstColNumberSngRow = Val(cl.Columns(1).Column)
msg = "Name of Sheet: " & wks.Name & " " & vbCrLf
j = -1
For Each x In wks.Rows(RowNumber).Cells
If x.Value = "" Then Exit For
j = j + 1
ReDim Preserve heading(j) As String
heading(j) = x.Value & " " & x.Column & vbCrLf
ColValStr = ColValStr & heading(j)
Next x
msg = msg & ColValStr
MsgBox msg
Next wks
End Sub
SamD
124
Last edited: