Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to Check Empty Rows in Sheet2 when sheet1 buton clicked


Code:
--------------------

Private Sub CommandButton1_Click()
Dim value, acCell As String
Dim FoundRange As Range
Dim chkEmpty As Integer
Dim aCell As String

value = Sheets("ValidationLists").Range("A1").value

On Error Resume Next
Set FoundRange = Range("A18:F37").Find(What:=value, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext).Activate
acCell = ActiveCell.Address
Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy

'Sheets("Matter Arrising").activate : Problem1


Sheets("Matter Arrising").Range("A2").selct
aCell = Sheets("Matter Arrising").Range(ActiveCell, ActiveCell.Offset(0, 7)).Address
MsgBox "Range are " & aCell

chkEmpty = Sheets("Matter Arrising").Application.CountA(Sheets("Matter Arrising").Range(aCell))
MsgBox "1.) There are " & chkEmpty & " of Records"

If chkEmpty = 0 Then
MsgBox "No Record"
Else
MsgBox "Records Found"
End If

End Sub

--------------------


In My Sheet 1 I have one Button1 to click, then copy after the find
value and paste to sheet2 or Sheets("Matter Arrising"). Before paste to
Sheet2, I have used check empty rows to check whether the rows is empty
or not.

Problem1 :If Sheets("Matter Arrising") is not selected, my checking
emtpy rows is not work. I need user only click the button on sheet1
without going see any sheet2.

Is there any way to check empty rows in Sheet 2 when button1 is clicked
in sheet1?

Rgds
Bernard Ng


--
bernardng
------------------------------------------------------------------------
bernardng's Profile: http://www.excelforum.com/member.php...o&userid=34117
View this thread: http://www.excelforum.com/showthread...hreadid=544212

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to Check Empty Rows in Sheet2 when sheet1 buton clicked

Hi Bernard

Try something like this

With Workbooks("Book1").Worksheets("Matter Arrising").Cells(2, 1)
If Workbooks("Book1").Worksheets("ValidationLists").C ells(2, 1) = ""
Then
ActiveCell.Offset(0, 4).Copy
Destination:=Workbooks("Book1").Worksheets("Matter
Arrising").Range("A2")
Else
MsgBox ("The paste cell is not empty")
End If
End With

This is checking the paste cell if it is empty and then copying the
value
You have to change the Workbook name.

Cheers
Christian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default How to Check Empty Rows in Sheet2 when sheet1 buton clicked

Try this:

Private Sub CommandButton1_Click()
Dim value, acCell As String
Dim FoundRange As Range
Dim chkEmpty As Integer
'Dim aCell As String

value = Sheets("ValidationLists").Range("A1").value

On Error Resume Next
Set FoundRange = Range("A18:F37").Find(What:=value, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext).Activate
acCell = ActiveCell.Address
Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy

'Sheets("Matter Arrising").Activate : Problem1


'Sheets("Matter Arrising").Range("A2").Select
'aCell = Sheets("Matter Arrising").Range("A2:H2")
'MsgBox "Range are " & aCell

chkEmpty = WorksheetFunction.CountA(Sheets("Matter
Arrising").Range("A2:H2"))
MsgBox "1.) There are " & chkEmpty & " of Records"

If chkEmpty = 0 Then
MsgBox ("No Record")
Else
MsgBox (chkEmpty & " Records Found")
End If

End Sub

Mike F
"bernardng" wrote in
message ...

Code:
--------------------

Private Sub CommandButton1_Click()
Dim value, acCell As String
Dim FoundRange As Range
Dim chkEmpty As Integer
Dim aCell As String

value = Sheets("ValidationLists").Range("A1").value

On Error Resume Next
Set FoundRange = Range("A18:F37").Find(What:=value, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext).Activate
acCell = ActiveCell.Address
Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy

'Sheets("Matter Arrising").activate : Problem1


Sheets("Matter Arrising").Range("A2").selct
aCell = Sheets("Matter Arrising").Range(ActiveCell, ActiveCell.Offset(0,
7)).Address
MsgBox "Range are " & aCell

chkEmpty = Sheets("Matter Arrising").Application.CountA(Sheets("Matter
Arrising").Range(aCell))
MsgBox "1.) There are " & chkEmpty & " of Records"

If chkEmpty = 0 Then
MsgBox "No Record"
Else
MsgBox "Records Found"
End If

End Sub

--------------------


In My Sheet 1 I have one Button1 to click, then copy after the find
value and paste to sheet2 or Sheets("Matter Arrising"). Before paste to
Sheet2, I have used check empty rows to check whether the rows is empty
or not.

Problem1 :If Sheets("Matter Arrising") is not selected, my checking
emtpy rows is not work. I need user only click the button on sheet1
without going see any sheet2.

Is there any way to check empty rows in Sheet 2 when button1 is clicked
in sheet1?

Rgds
Bernard Ng


--
bernardng
------------------------------------------------------------------------
bernardng's Profile:
http://www.excelforum.com/member.php...o&userid=34117
View this thread: http://www.excelforum.com/showthread...hreadid=544212



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to have Sheet1 list Sheet2 rows matching text? DevourU Excel Worksheet Functions 7 May 14th 10 09:07 PM
copy data from sheet2 to sheet1 when sheet2 has variable # of rows Anne Excel Discussion (Misc queries) 6 February 27th 09 09:48 PM
+/- in sheet2 based on conditions and dynamic rows in sheet1 deepika :excel help[_2_] Excel Discussion (Misc queries) 0 February 4th 08 08:33 AM
[=Sheet1!A1] - if i use Column A1 ('Sheet1') / A2 ('Sheet2') Lawrence C H Tan Excel Worksheet Functions 0 January 19th 07 08:29 PM
Display Rows From Sheet1 In Sheet2 (Import) Mythran Excel Worksheet Functions 1 March 24th 06 07:40 PM


All times are GMT +1. The time now is 08:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"