Need Greater Control for Read then write to another sheet

robertlozar

New Member
Joined
Apr 7, 2011
Messages
3
Hello, I am very new to VBA. I need to generate a report from excel output into an Excel report page. I found the example Macro "MoveActiveRowAtoC" which has been the model for my work so far. It does well for anything in the first column. I have been frustrated in that I want to check to see if there is something in the second column which also needs to be printed on the second sheet in the second column - and thus also search the third and fourth columns for similar text that should be printed to the next available row on sheet2. Below is my current version, but I know there must be a better way. Can someone help please?
Thank you, Bob
Using Excel 2010
Sub MoveActiveRowAtoC()
'If there is an entry in the current cell of the first sheet, place 3 columns in sheet2
Dim lst As Long 'line in sheet2
Dim CurrRw As Long 'current row in sheet1
Dim Time As Long
Dim NextFreeRow As Long
Time = 1
CurrRw = 1
Do While Time <= 11
NextFreeRow = 1
lst = Sheet2.Range("A" & Rows.Count).End(xlUp).Row + 1
If ActiveSheet.Name <> "Sheet1" Then Exit Sub
If lst >= 20 Then 'alter to be the last row of table
MsgBox "Table Limit Reached!!, data will not be copied"
Exit Sub
End If
With Sheet2.Range("A1:A3").Font 'Format Title Rows 1 to 3
.Bold = True
.Size = 15
.ColorIndex = 5
End With
NextFreeRow = lst + 1
Cells(CurrRw, 1).Resize(1, 3).Copy Sheet2.Cells(lst, 1) 'copy columns A-c of ActiveRow to next available in Sheet2
Sheet2.Cells(lst, 1).Font.Size = 14
Cells(CurrRw + 1, 2).Resize(1, 3).Copy Sheet2.Cells(NextFreeRow, 1)
Time = Time + 1
CurrRw = CurrRw + 1
Loop
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
To make the discussion a little clearer, here is some sample data. I would like to go from an Excel display that looks like this (dots indicate spaces in this MrExcel editor):

Potential Emergencies / Disasters and Risk Report
Camden has its greatest disaster risk to utilities from:
.....Earthquakes with no warning for:
..........below ground electrical, .........natural gas,
..........propane/fuel oil,
.
.
.
....Hurricanes with days warning for :
..........Above ground electrical,
..........potable water,

to a more nicely formated display (removing blank rows and blank columns in a row) similar to this:

Potential Emergencies / Disasters and Risk Report
Camden has its greatest disaster risk to utilities from:
.....Earthquakes with no warning for:
..........below ground electrical, natural gas, propane/fuel oil,
.....Hurricanes with days warning for :
..........Above ground electrical, potable water,

Thanks, Bob
 
Upvote 0
I know this must look really easy to many of you out there, but I have not been able to make progress on this for days. Could someone help please.
Thank you, Bob
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top