Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]() Hi, I have a macro that I am trying to edit, but I am not having much luck. Right now, when the macro runs, it searches through a selection of worksheets, outputs the name of each worksheet, and then lists the cells that are not blank, in a specified range. So the output looks like this Worksheet 1 Cell 2 Cell 5 Worksheet 2 Cell 1 Worksheet 3 Cell 3 Cell 4 Cell 6 The range that is selected to be searched through is one column, for example, D9:D65. What I am trying to do, is have the range be multiple columns, for example, D9:F65, and then have the macro output each column under its worksheet name, like this. (this is considering there was a two column range) Worksheet 1 Cell 2 Cell 5 Worksheet 1 Cell 3 Cell 5 Worksheet 2 Cell 1 Cell 3 Worksheet 2 Cell 2 Cell 3 What I have written so far gives me an output looking something like that, but it only searches through one column of cells. So instead it looks like this: Worksheet 1 Cell 2 Cell 5 Worksheet 1 Cell 2 Cell 5 Worksheet 2 Cell 1 Cell 3 Worksheet 2 Cell 1 Cell 3 I do not know how to make it search through one column the first time, then move to another column the next time, and so on. If anyone has any ideas that would be a big help. Here is my code so far: Sub PeopleSearch() Dim W As Worksheet Dim range_input, raange_input, b_range, e_range As Range Dim VAL, sh_skip, temp As Variant sh_skip = "Summary" 'sheetname to skip VALU = InputBox("Enter a week range (number of columns to be searched through, ex. D7:F7)") Set raange_input = Range(VALU) VAL = InputBox("Enter which range to search in: (ex. D9:D62)") Set range_input = Range(VAL) For Each W In Worksheets W.Select For Each b_range In raange_input If W.Name < "Summary" Then temp = temp & Chr(10) & W.Name & Chr(10) End If For Each e_range In range_input If W.Name < sh_skip Then If Trim(W.Range(e_range.Address).Value) < "" And Trim(W.Range(e_range.Address).Value) < "0" Then temp = temp & W.Range("b" & e_range.Row).Value & Chr(10) End If End If Next Next Next Workbooks.Add Range("a1").Select Selection.Value = "CURRENT PROJECTS LIST" Selection.Font.Bold = True temp1 = Split(temp, Chr(10)) Range("a2").Select For i = 0 To UBound(temp1) Selection.Value = temp1(i) If ActiveCell.Characters.Count 13 Or Not only_text(ActiveCell) Or ActiveCell.Value = "RM UCONN SFA" Then ActiveCell.Font.Bold = True End If ActiveCell.Offset(1, 0).Select Next Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:= _ "file", _ FileFormat:=xlNormal, _ Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _ CreateBackup:=False ActiveWorkbook.Save ActiveWorkbook.Close Application.DisplayAlerts = True Workbooks.OpenText Filename:="file" End Sub -- thephoenix12 ------------------------------------------------------------------------ thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336 View this thread: http://www.excelforum.com/showthread...hreadid=386890 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help with macro looping and color query function | Excel Discussion (Misc queries) | |||
Playing a macro from another workbook | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) | |||
Macro and If Statement | Excel Discussion (Misc queries) | |||
Macro Formula revision? | Excel Worksheet Functions |