ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Refinement involving blank cell(s) (https://www.excelbanter.com/excel-programming/299991-code-refinement-involving-blank-cell-s.html)

robbyn

Code Refinement involving blank cell(s)
 
I use the following code snippet to create individual student reports from my gradebook. The code copies grades from the worksheet onto a report created using vba. Sometimes the cell which contains the student's first grade is empty, so I need the first grade on the report to be empty. I just can't figure out how to get the code to reflect that. Any advice would be appreciated

Private Sub OKButton_Click(
Dim RowRange As Rang
Dim RowCnt As Intege
Dim r As Intege
Dim wsNew As Workshee
Dim wsSource As Workshee
Dim rng As Rang
Dim myCmt As Commen


Application.ScreenUpdating = Fals
Set wsSource = ActiveShee
RowCnt =
For r = 0 To ListBox1.ListCount - 1 'Count student row
If ListBox1.Selected(r) The
RowCnt = RowCnt +
Set RowRange = ActiveSheet.Range("A15").Rows(r + 1
End I
Next

RowRange.Select 'Copy student grade
Set LeftCell = Cells(ActiveCell.Row, 8
Set RightCell = Cells(ActiveCell.Row, 256

Set LeftCell = LeftCell.End(xlToRight
Set RightCell = RightCell.End(xlToLeft
If LeftCell.Column = 256 And RightCell.Column = 8 Then ActiveCell.Selec
Set rng = Range(LeftCell, RightCell
rng.Cop

Set wsNew = Worksheets.Add 'Paste student grades to Report
wsNew.Name = "Report" & UserForm1.ListBox1.Valu
With wsNew.Range("f14"
.PasteSpecial Paste:=xlPasteValues, Transpose:=Tru
End Wit

Thanks for your help

Robbyn

robbyn

Code Refinement involving blank cell(s)
 
Nevermind. Fixed it. Yet another premature post. :

Robbyn


All times are GMT +1. The time now is 02:00 AM.

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