Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default The sheet name to copy to is in column H of the If Statement row

Having trouble making shtTo be the sheet name to copy to in the If
statement. Where the names in column H are an actual sheet name, (in
this case a persons name) Ted, Allen, Kelly etc.

Thanks,
Howard


Sub Column_Check_OneRng()

Dim rngB As Range
Dim OneRng As Range
Dim shtTo As Worksheet

Application.ScreenUpdating = False

Set OneRng = Sheets("Bid log").Range("A2:A" & Cells(Rows.Count,
"A").End(xlUp).Row)

For Each rngB In OneRng

If rngB.Offset(, 3) = "D-Col Bid" Then
'set shtTo to the name in column H which is a sheet name to
copy to shtTo.Range("B" & Rows.Count).End(xlUp)(2) = rngB

End If

Next

Application.ScreenUpdating = True

End Sub


shtTo is an object that *must* be initialized via a 'Set' statement!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default The sheet name to copy to is in column H of the If Statement row


shtTo is an object that *must* be initialized via a 'Set' statement!

--
Garry


Hi Garry,

It is the syntax I can't get together with, this still errors out.


Sub Column_Check_OneRng()

Dim rngB As Range
Dim OneRng As Range
Dim shtTo As Worksheet

Application.ScreenUpdating = False

Set OneRng = Sheets("Bid log").Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)

For Each rngB In OneRng

If rngB.Offset(, 3) = "D-Col Bid" Then

Set shtTo = rngB.Offset(, 7)

If Not shtTo Is Nothing Then
shtTo.Range("B" & Rows.Count).End(xlUp)(2) = rngB
End If

End If

Next

Application.ScreenUpdating = True

End Sub

Howard
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default The sheet name to copy to is in column H of the If Statement row

shtTo is dimmed 'As Worksheet', but you're trying to 'Set' it to a
range and VBA knows the difference between the two objects. I know you
also know the difference but for some reason you're a bit confused
right now. Take a step back to clear your mind, then have another go at
it!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Code to copy column in sheet 1 to column in sheet 2 based on matched criteria skitsoni Excel Programming 1 July 14th 12 11:25 AM
Match value from column A to column A on 2nd sheet and then copy R DanS Excel Programming 2 February 16th 09 09:03 PM
copy cells from multiple pages to one sheet w/ if statement GHall Excel Worksheet Functions 8 January 15th 09 08:24 PM
How to search column, copy row, and copy to another sheet in same Rockhound Excel Discussion (Misc queries) 1 December 9th 06 04:16 PM
how to make one column copy from one sheet to anoth column w/o zer areezm Excel Discussion (Misc queries) 3 June 6th 06 10:45 PM


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

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

About Us

"It's about Microsoft Excel"