I have written the code for getting the blank cell information but the problem is that I want to copy the data which are before the blank call. After the blank cell there might be a value. Here’s my code:
Set rng = Range("6:6").Find(What:=horiz, LookIn:=xlValues, LookAt:=xlWhole)
If rng Is Nothing Then
MsgBox "Value not found in row 1", vbExclamation
Else
rng.EntireColumn.Copy
Range("p1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
MsgBox Range("C1").End(xlDown)(2, 1).Value
I can’t really see your data set, so hard to say this is bullet proof, but from what your post says, this may be what you need.
Change
rng.EntireColumn.Copy(which copies the entire column)to
Range(rng, rng.end(xlDown)).Copywhich copies the range from the found range to the last cell before a blank.If you want to copy all the cells above the found range, until you find a blank above, and all the cells below, write this:
Range(rng.End(xlUp), rng.End(xlDown)).Copy