Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find and blank cell then Do this.....

Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and do
a copy, go up one cell, paste special/value. Then go back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in column S
How can I define the "range" in S so that I do not have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find and blank cell then Do this.....

if the cells are really blank

Sub WorkonS()
dim rng as rng, cell as range
On error resume next
set rng = Columns(7).specialCells(xlBlanks)
On error goto 0
if rng is nothing then
msgbox "No blanks in Column G"
exit sub
End if
set rng = Intersect(rng.EntireRow, Range("S1").EntireColumn)
for each cell in rng
cell.offset(-1,0).Value = cell.value
Next
end Sub

--
Regards,
Tom Ogilvy


Bonnie wrote in message
...
Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and do
a copy, go up one cell, paste special/value. Then go back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in column S
How can I define the "range" in S so that I do not have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Find and blank cell then Do this.....

One way:

Public Sub test1()
Dim cell As Range
On Error Resume Next
For Each cell In Columns("G").SpecialCells(xlCellTypeBlanks)
With cell.Offset(0, 12) 'Column S
.Offset(-1, 0).Value = .Value
End With
Next cell
on Error GoTo 0
End Sub

Note that you almost never need to select/activate. Working with the
range objects directly results in code that is smaller, faster, and
in my opinion, easier to maintain.

The On Error Resume Next is necessary since SpecialCells() will
throw an error if there are no blank cells in column G.

In article ,
"Bonnie" wrote:

Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and do
a copy, go up one cell, paste special/value. Then go back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in column S
How can I define the "range" in S so that I do not have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find and blank cell then Do this.....

I am getting a complie error on
"Dim rng As rng"


-----Original Message-----
if the cells are really blank

Sub WorkonS()
dim rng as rng, cell as range
On error resume next
set rng = Columns(7).specialCells(xlBlanks)
On error goto 0
if rng is nothing then
msgbox "No blanks in Column G"
exit sub
End if
set rng = Intersect(rng.EntireRow, Range

("S1").EntireColumn)
for each cell in rng
cell.offset(-1,0).Value = cell.value
Next
end Sub

--
Regards,
Tom Ogilvy


Bonnie wrote in

message
...
Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and

do
a copy, go up one cell, paste special/value. Then go

back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in

column S
How can I define the "range" in S so that I do not have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find and blank cell then Do this.....

THANK YOU!!!!!!
-----Original Message-----
if the cells are really blank

Sub WorkonS()
dim rng as rng, cell as range
On error resume next
set rng = Columns(7).specialCells(xlBlanks)
On error goto 0
if rng is nothing then
msgbox "No blanks in Column G"
exit sub
End if
set rng = Intersect(rng.EntireRow, Range

("S1").EntireColumn)
for each cell in rng
cell.offset(-1,0).Value = cell.value
Next
end Sub

--
Regards,
Tom Ogilvy


Bonnie wrote in

message
...
Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and

do
a copy, go up one cell, paste special/value. Then go

back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in

column S
How can I define the "range" in S so that I do not have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Find and blank cell then Do this.....

THANK YOU!!!!!!
-----Original Message-----
One way:

Public Sub test1()
Dim cell As Range
On Error Resume Next
For Each cell In Columns("G").SpecialCells

(xlCellTypeBlanks)
With cell.Offset(0, 12) 'Column S
.Offset(-1, 0).Value = .Value
End With
Next cell
on Error GoTo 0
End Sub

Note that you almost never need to select/activate.

Working with the
range objects directly results in code that is smaller,

faster, and
in my opinion, easier to maintain.

The On Error Resume Next is necessary since SpecialCells

() will
throw an error if there are no blank cells in column G.

In article ,
"Bonnie" wrote:

Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and

do
a copy, go up one cell, paste special/value. Then go

back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in

column S
How can I define the "range" in S so that I do not

have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub

.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find and blank cell then Do this.....

typo

Sub WorkonS()
Dim rng As Range, cell As Range
On Error Resume Next
Set rng = Columns(7).SpecialCells(xlBlanks)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "No blanks in Column G"
Exit Sub
End If
Set rng = Intersect(rng.EntireRow, Range("S1").EntireColumn)
For Each cell In rng
cell.Offset(-1, 0).Value = cell.Value
Next
End Sub

Tested in xl97

--
Regards,
Tom Ogilvy


Bonnie wrote in message
...
I am getting a complie error on
"Dim rng As rng"


-----Original Message-----
if the cells are really blank

Sub WorkonS()
dim rng as rng, cell as range
On error resume next
set rng = Columns(7).specialCells(xlBlanks)
On error goto 0
if rng is nothing then
msgbox "No blanks in Column G"
exit sub
End if
set rng = Intersect(rng.EntireRow, Range

("S1").EntireColumn)
for each cell in rng
cell.offset(-1,0).Value = cell.value
Next
end Sub

--
Regards,
Tom Ogilvy


Bonnie wrote in

message
...
Hello All
I hope someone can help me with this ASAP

I have a Sheet that in column G I want my VBA to look
down for a blank cell, when it finds a blank cell goto
column S (same row that the blank in G was found) and

do
a copy, go up one cell, paste special/value. Then go

back
G and continue on..etc. etc.

this is what I have so far
and it works, but only for one copy and paste in

column S
How can I define the "range" in S so that I do not have
to use a cell ref. exp. "S3"

Any help would be good
Thank you!!

Sub CopyPaste()

Dim Counter
Dim i As Integer

Counter = 600
Range("g1").Select
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Range("S3").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

Else
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub



.



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
Find the first blank row in a cell Chris Anderson Excel Discussion (Misc queries) 6 November 7th 08 04:08 PM
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
Find 1st blank cell in column & sum to the same row in another col Sharon Excel Worksheet Functions 2 March 7th 07 03:00 AM
IF function which can find a blank cell owl37 Excel Worksheet Functions 5 October 19th 06 05:48 PM
find the first and last non blank cell in a row Allan from Melbourne Excel Discussion (Misc queries) 3 May 19th 06 01:12 PM


All times are GMT +1. The time now is 01:41 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"